2010-10-18 8 views
2

Je suis nouveau sur android. Je veux maintenant comment créer une barre de notification d'état dans la page d'accueil. Quelqu'un peut-il m'aider avec certains codes. Merci d'avance.Barre d'état Android Notification

Répondre

5
notificationManager = (NotificationManager)_context.getSystemService(Context.NOTIFICATION_SERVICE); 
long when = System.currentTimeMillis(); 
int _icon=R.drawable.icon; 

Intent intent = new Intent(_context, your_file.class); 

PendingIntent contentIntent = PendingIntent.getActivity(_context, 0, intent, 0); 

Notification notification = new Notification(_icon,_text,when); 
notification.setLatestEventInfo(_context, _title, _contentText, contentIntent); 
int NOTIFICATION_ID = 10; 
notificationManager.notify(NOTIFICATION_ID, notification); 

Pour annuler la notification

notificationManager.cancel(NOTIFICATION_ID); 
+0

comment nous pouvons montrer le pourcentage dowload dans la boîte de dialogue de progression dans la notification d'état de bar ...? –

+0

@kamal: http://united-coders.com/nico-heid/show-progressbar-in-notification-area-like-google-does-when-downloading-from-android – viv

+0

Mais comment ajouter les progrès de 55% sous la barre de progression ...? –

Questions connexes