The example in this article tells the Android implementation status bar to add an icon function. Share to everyone for your reference. as follows:
private void Shownotification () {//Create a Notificationmanager reference Notificationmanager Notificationmanager = (notificati
Onmanager) AutoFile.this.getSystemService (Android.content.Context.NOTIFICATION_SERVICE); Defines the various attributes of Notification Notification Notification = new Notification (R.drawable.dvd, "Sound player", System.currenttimemill
Is ()); Notification.flags |= notification.flag_ongoing_event; Place this notice in the "ongoing", the "Running" group, in the notification bar notification.flags |= notification.flag_no_clear;
Indicates that after clicking on the "clear notice" in the notification bar, this notice is not cleared, often with flag_ongoing_event to use Notification.flags |= notification.flag_show_lights;
Notification.defaults = notification.default_lights;
Notification.ledargb = Color.Blue;
NOTIFICATION.LEDONMS = 5000; Set the event message for the notification charsequence contenttitle = "The sounds of nature are playing ..."; Notice Bar title Charsequence ContentText = "Ameyume"; Notification bar content Intent notificationintent = new Intent (autofile.this, Myplayerservice.class); Click on the notification to jump to the activity pendingintent contentitent = pendingintent.getactivity (autofIle.this, 0, notificationintent, 0);
Notification.setlatesteventinfo (Autofile.this, Contenttitle, ContentText, contentitent);
Pass the notification to Notificationmanager notificationmanager.notify (0, notification);
}
To remove an icon, use the following code:
After startup delete We define the notification
Notificationmanager Notificationmanager = (Notificationmanager) this
. Getsystemservice ( Notification_service);
Notificationmanager.cancel (0);
I hope this article will help you with your Android program.