2010-08-25 6 views
-1

Hos puis-je faire une liste avec des notifications dans la barre de notification (le menu déroulant avec le mode de connexion USB, etc.)?Notification Android

+4

s'il vous plaît être clair avec ce que vous voulez. Ceci est très vague – the100rabh

+0

S'il vous plaît visitez [ce lien pour la mise à jour de la réponse] (http://stackoverflow.com/a/35913469/2826147). –

Répondre

4

Allez mec c'est une chose standard:

http://developer.android.com/guide/topics/ui/notifiers/notifications.html

String ns = Context.NOTIFICATION_SERVICE; 
NotificationManager mNotificationManager = 
             (NotificationManager) getSystemService(ns); 

int icon = android.R.drawable.ic_media_play; 
CharSequence ticketText = "Now - Playing"; 
long when = System.currentTimeMillis(); 

Notification notification = new Notification(icon, ticketText, when); 

Context context = getApplicationContext(); 
CharSequence contentTitle = "Now"; 
CharSequence contentText = "Session"; 
Intent notificationIntent = new Intent(this, PlayTrack.class); 
notificationIntent.addFlags(Notification.FLAG_ONGOING_EVENT); 
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, 
             notificationIntent, 0); 

notification.setLatestEventInfo(context, contentTitle,contentText,contentIntent); 

mNotificationManager.notify(CONFIDENCE_NOW_ID, notification); 
Questions connexes