build.setOngoing(true);
build.setAutoCancel(false);
notification.flags= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
setOngoing не работает
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
/* Create or update. */
_notificationChannel = new NotificationChannel("TubeMateGo",
"Downlaod File Notification",
NotificationManager.IMPORTANCE_DEFAULT);
mNotifyManager.createNotificationChannel(_notificationChannel);
build = new NotificationCompat.Builder(getBaseContext(),_notificationChannel.getId());
build.setContentTitle("Download")
.setContentText("Download in progress")
.setSmallIcon(R.drawable.ic_launcher_foreground);
build.setOngoing(true);
build.setChannelId(_notificationChannel.getId());
build.setVisibility(Notification.VISIBILITY_PUBLIC);
build.setAutoCancel(false);
build.setContentIntent(_pedingIntent);
Notification notification = build.build();
notification.flags= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
mNotifyManager.notify(id, notification);
}
else {
build = new NotificationCompat.Builder(getBaseContext());
build.setContentTitle("Download")
.setContentText("Download in progress")
.setSmallIcon(R.drawable.ic_launcher_foreground);
build.setOngoing(true);
build.setVisibility(Notification.VISIBILITY_PUBLIC);
Notification notification = build.build();
notification.flags=Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
mNotifyManager.notify(id, notification);
}
Когда я пытаюсь удалить уведомление из панели уведомлений, оно удаляется, почему?
Я не знаю, где я иду не так
По документам
public Notification.Builder setOngoing (boolean ongoing)
Установите, является ли это "текущим" уведомлением. Постоянные уведомления
не может быть отклонено пользователем, поэтому ваше приложение или служба должны
позаботься об их отмене. Они обычно используются для обозначения
фоновая задача, которой пользователь активно занимается (например, игра
музыка) или находится в ожидании в некотором роде и поэтому занимает устройство
(например, загрузка файла, операция синхронизации, активное сетевое соединение).
Тогда почему его уволили?
РЕДАКТИРОВАТЬ 2
Это происходит в пользовательских ОС? Как Vivo
Тест - RedMI note 5 Pro - работает нормально
Тогда почему ? Не работает с Vivo?