2010-10-19 7 views
4

im suivant le tutoriel du guide des développeurs, mais j'ai un problème ...Comment ajouter des drapeaux à une notification (notification de la barre d'état)?

tutoriel dit: « Pour effacer la notification de la barre d'état lorsque l'utilisateur sélectionne dans la fenêtre Notifications, ajoutez le « drapeau FLAG_AUTO_CANCEL » à votre notification objet »

mais ... comment je peux ajouter le drapeau à ma notification?

notification n'a aucune sorte de fonction pour ajouter des drapeaux .... alors? comment je peux le faire?

Répondre

2

Les drapeaux vont à la fin lorsque vous définissez l'intention, comme ceci:

PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, notifyIntent, Notification.FLAG_AUTO_CANCEL); 
+2

-1 'Notification.FLAG_AUTO_CANCEL' ne devrait pas y aller. http://developer.android.com/reference/android/app/PendingIntent.html –

+0

alors où devrait-il aller à la place? :) – bofredo

+0

cela ne fonctionne pas pour moi –

15

drapeaux de notification est un champ de membre du public.

Notification notif = new Notification(R.drawable.icon, shortMsg, 
       System.currentTimeMillis()); 
notif.flags |= Notification.FLAG_AUTO_CANCEL; 
Questions connexes