Этот флаг делает ваше уведомление палкой: Уведомление.FLAG_ONGOING_EVENT;
Если вы оставите его, его можно удалить. Если вы положите его, он будет придерживаться.
FYI: Как сделать мои уведомления:
//These are parameters for setting up the tag in the tray
private static final String NOTIFICATION_ID_TAG="notificationID";
private static final int NOTIFICATION_ID=123456;
public void createNotification() {
// Prepare intent which is triggered if the
// notification is selected
Intent intent = new Intent(this, MainActivity_Host.class);
intent.putExtra(NOTIFICATION_ID_TAG, NOTIFICATION_ID);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
// Build notification
Notification noti = new Notification.Builder(this)
.setContentTitle("Service Running")
.setContentText("The service is running").setSmallIcon(R.mipmap.ic_launcher)
.setContentIntent(pIntent)
.build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
//THIS FLAG MAKES THE NOTIFICATION STICK = YOU CAN'T SWIPE IT AWAY... IF YOU LEAVE IT OUT YOU CAN REMOVE THE NOTIFICATION
noti.flags |= Notification.FLAG_ONGOING_EVENT;
notificationManager.notify(NOTIFICATION_ID, noti);
}
Это, как вы можете удалить уведомление из кода:
//Erase the notification that we set up when the service started
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(NOTIFICATION_ID);
Как вы видите, вы можете получить уведомление от NotificationManager с помощью NOTIFICATION_ID, который вы использовали для его создания. Это всего лишь номер, который я составил.
Как вы строите свое уведомление? Можете ли вы включить этот код? – ianhanniballake
Я еще не сделал уведомление для своего приложения, так как хочу использовать это как часть моего уведомления, но не был уверен, насколько это будет легко. приложения, которые я заметил это, - это сообщения sms/email, которые не поддаются исправлению, а напоминание AIDE является неприемлемым. – John