Questo è possibile ma il modo in cui lo si implementa dipende dal livello API per il quale si sviluppa.
Per i livelli API inferiori a 11, è possibile impostare Notification.FLAG_NO_CLEAR. Ciò può essere implementato in questo modo:
// Create notification
Notification note = new Notification(R.drawable.your_icon, "Example notification", System.currentTimeMillis());
// Set notification message
note.setLatestEventInfo(context, "Some text", "Some more text", clickIntent);
// THIS LINE IS THE IMPORTANT ONE
// This notification will not be cleared by swiping or by pressing "Clear all"
note.flags |= Notification.FLAG_NO_CLEAR;
Per livelli di API superiore a 11, o quando si utilizza il Android Support Library, si può implementare in questo modo:
Notification noti = new Notification.Builder(mContext)
.setContentTitle("Notification title")
.setContentText("Notification content")
.setSmallIcon(R.drawable.yourIcon)
.setLargeIcon(R.drawable.yourBigIcon)
.setOngoing(true) // Again, THIS is the important line
.build();
In combitation con il post di antew, io ero esattamente cercando Notification.FLAG_ONGOING_EVENT. molte grazie – Kelib