A notification is used to display messages in the status bar. When a message arrives, it is represented by an icon as follows:
To view a message, drag the status bar to the bottom of the screen to view the message.
TheCodeAs follows:
// Obtain the notification Manager
Icationicationmanager mnotificationmanager = (notificationmanager) getsystemservice (context. icationication_service );
Int icon = Android. R. drawable. stat_policy_chat;
Long when = system. currenttimemillis ();
// Create a notification and specify its icon and title
Notification = new notification (icon, null, when); // The first parameter is the icon, the second parameter is the title, and the third parameter is the notification time.
Notification. defaults = notification. default_sound; // send the default sound
Intent openintent = new intent (this, otheractivity. Class );
Pendingintent contentintent = pendingintent. getactivity (this, 0, openintent, 0); // The openintent intent is sent to the system when a message is clicked.
notification. setlatesteventinfo (this, "title", "I am content", contentintent);
micationicationmanager. Y (0, notification); // The first parameter is the unique identifier of the custom notification