Android Learning notes---Send status bar notifications

Source: Internet
Author: User

The code to send the message is as follows:
Get Notification Manager
Notificationmanager Mnotificationmanager = (notificationmanager) getsystemservice (Context.notification_service);
int icon = Android. R.drawable.stat_notify_chat;
Long when = System.currenttimemillis ();
Create a new notification that specifies its icon and caption
Notification Notification = new Notification (icon, null, when);//The first parameter is an icon, the second argument is a caption, and the third is the notification time
Notification.defaults = notification.default_sound;//emits default sound
Intent openintent = new Intent (this, otheractivity.class);
Pendingintent contentintent = pendingintent.getactivity (this, 0, openintent, 0);//When a message is clicked, the openintent intent is sent to the system
Notification.setlatesteventinfo (This, "title", "I am Content", contentintent);
Mnotificationmanager.notify (0, notification);//The first parameter is a custom notification unique identifier

Excerpted from Lhttp://www.tuicool.com/articles/mjuuzi

Android Learning notes---Send status bar notifications

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.