Android - Gardez la notification stable à la barre de notification
J'ai écrit la fonction de notifier et de l'écran de Notification de la barre:
private void showNotification()
{
CharSequence title = "Hello";
CharSequence message = "Notification Demo";
NotificationManager notificationManager = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, "A Notification", System.currentTimeMillis());
Intent notificationIntent = new Intent(this, Main_Activity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(Main_Activity.this, title, message, pendingIntent);
notificationManager.notify(NOTIFICATION_ID, notification);
}
Sa fonctionne très bien, Mais what way we can keep the notification steady at Notification bar
même lorsque l'utilisateur appuyez sur la touche "clear" notificatios bouton de la barre de notification ?
Jetez un oeil à la "Yahoo" de l'application barre de notification.
Je suis passé par ce SDK de l'article: http://developer.android.com/guide/topics/ui/notifiers/notifications.html#Updating , mais a échoué à trouver.
source d'informationauteur Paresh Mayani
Vous devez vous connecter pour publier un commentaire.
Utilisation
FLAG_NO_CLEAR
Il suffit de le mettre sur votre
Notification
instance avant de le fournir à l'NotificationManager
:edit: je viens de remarquer cependant que si vous utilisez
Notification.Builder
(depuis le Nid d'abeille) et de procéder à la notification "en cours", il sera également devenir immunitaire à "effacer tout". Voir ici.Appearently, c'est censé décourager les développeurs d'utiliser le
FLAG_NO_CLEAR
sur un non permanent notificaton, car cela pourrait perturber l'utilisateur.Essayer setOngoing(true).