Home>
private void shownotification () {
 //create a reference to notificationmanager
 notificationmanager notificationmanager=(notificationmanager)
  autofile.this.getsystemservice (android.content.context.notification_service);
 //Define various properties of notification
 notification notification=new notification (r.drawable.dvd,  "Tianzhizhi Player", system.currenttimemillis ());
 notification.flags |=notification.flag_ongoing_event;//Place this notification in the "ongoing" or "running" group of the notification bar
 notification.flags |=notification.flag_no_clear;//indicates that after clicking "clear notification" in the notification bar, this notification is not cleared,Often used with flag_ongoing_event
 notification.flags |=notification.flag_show_lights;
 notification.defaults=notification.default_lights;
 notification.ledargb=color.blue;
 notification.ledonms=5000;
 //Set notification event message
 charsequence contenttitle="The sound of nature sounds playing ...";//notification bar title
 charsequence contenttext="ameyume";//notification bar content
 intent notificationintent=new intent (autofile.this, myplayerservice.class);//activity to jump to after clicking the notification
 pendingintent contentitent=pendingintent.getactivity (autofile.this, 0,  notificationintent, 0);
 notification.setlatesteventinfo (autofile.this, contenttitle, contenttext,  contentitent);
 //pass notification to notificationmanager
 notificationmanager.notify (0, notification);
}

To delete the icon,With the following code:

//delete the notification we defined before the startup
notificationmanager notificationmanager=(notificationmanager) this
 .getsystemservice (notification_service);
notificationmanager.cancel (0);
  • Previous RHEL65 Compile and Install MySQL5626 Tutorial
  • Next Android implementation method to add headset status icon