Android status bar notification)

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.