1
Я показываю Notification
для фона Service
с использованием метода startForefround()
.Пользователь Android Отключает мое уведомление и возвращается в мое приложение
if (notif == null) {
// Create the pending intent
Intent intentForeground = new Intent(this, BackgroundLocationService.class)
.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent pendIntent = PendingIntent.getActivity(getApplicationContext(), 0, intentForeground, 0);
notif = new NotificationCompat.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher)
.setDefaults(Notification.DEFAULT_ALL)
.setTicker(getText(R.string.location_service_starting))
.setOnlyAlertOnce(true)
.setOngoing(true)
.setContentIntent(pendIntent)
.build();
notif.flags |= Notification.FLAG_NO_CLEAR;
}
startForeground(notificationID, notif);
Он правильно показывает уведомление пользователю, и когда я скольжу вниз панель уведомлений я хотел бы, чтобы пользователь нажмите на уведомление и вернуться в мое приложение. Как я могу это сделать?
Ах, я пропускал часть MainActivity.class. Благодаря! –