The notification of Android

Source: Internet
Author: User

To write like this:

public void OnCreate () {super.oncreate (); Ntfmngr = (Notificationmanager) getsystemservice (Notification_service); Setnotifytype (R.drawable.logo, "Aaaaaaaaaaa", 3);} private void Setnotifytype (int icon, String text, int num) {Intent notifyintent = new Intent (). SetClass (Getapplicationcont Ext (), mainactivity.class);//Notifyintent.putextra ("mode", Mnotifymode); Notifyintent.setaction (Constants.update_ Home_list); According to this received ACTIVITY can accept this action, determine what type of message//Notifyintent.setflags (Intent.flag_activity_clear_top |//intent.flag_ Activity_new_task); Pendingintent appintent = pendingintent.getactivity (this, 0,notifyintent, 0); Notification mynotification = new Notification ();//mynotification.defaults = Notification.default_vibrate; Uri Sounduri = Uri.parse ("Android.resource://com.sina.weibo/raw/notificationsound");//LOG.E (Constants.TAG, Sounduri.getpath ()); mynotification.flags = Notification.flag_auto_cancel;mynotification.icon = icon;<strong> Mynotification.defaults = Notification.default_sound;mynoTification.sound = Sounduri; When Notication came over, there was a voice. &LT;/STRONG&GT;IF (num! =-1) {mynotification.number = num;} Long[] vb = new long[] {};mynotification.vibrate = Vb;mynotification.tickertext = Text;mynotification.setlatesteve Ntinfo (This, getString (r.string.app_name), text, appintent); System.out.println ("====ntfmngr.notify"); <strong>ntfmngr.notify (Notify_message, mynotification); </strong><pre name= "code" class= "Java" ><strong>//notify_message to notification key, can be canceled according to key </strong>
}


You must add the appropriate permission to vibrate

<uses-permission android:name= "Android.permission.VIBRATE"/>

This can be done to cancel the notication:

if (Ntfmngr! = null) {Ntfmngr.cancelall ();}


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.