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. </STRONG>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 ();}