For Android Developers, they always hope that the programs they develop can be frequently used by users, so the most important thing is to directly access the programs where users can see them... The status bar notification is like this, such as QQ, 360, or other IM software.
So how to implement status bar notification?
A simple way to do this:
// Message Manager
Private icationicationmanager n_icationicationmanager;
Private pendingintent n_pendingintent;
// Notification object
Private notification n_notification;
Public void shownotification (INT dwrid)
{
// Initialize the message Manager
N_icationicationmanager = (notificationmanager) getsystemservice (notification_service );
// Set the page for displaying the content when you click the notification.
N_pendingintent = pendingintent. getactivity (icityactivity. This, 0, getintent (), 0 );
// Notification object
N_notification = new notification ();
// Set the icon of the notification displayed in the status bar
N_icationication.icon = dwrid;
// Content displayed when we click the notification
N_notification.tickertext = "Akemi is starting cosmic-level equipment. Please wait .....";
// Send the default sound during notification
N_notification.defaults = notification. default_sound;
// Set the notification display parameters
N_icationication.setlatesteventinfo (icityactivity. This, "Akemi", "Akemi, bringing you infinite happiness", n_pendingintent );
// It can be understood as executing this notification
N_notificationmanager.policy (0, n_notification );
}
Call the activity when it is started, and give the icon ID
Remember:
Protected void ondestroy (){
// Clear it
N_notificationmanager.cancelall ();
Super. ondestroy ();
}