Notificationmanager manager = (Notificationmanager) getsystemservice (Notification_service); Notificationcompat.builder Mbuilder = new Notificationcompat.builder (demo10activity.this); Mbuilder.setcontenttitle ("test title")//Set the notification bar header. Setcontenttext ("Test Content"). Setticker ("Test notifications come Up")//notifications first appear in the notification bar, with an upward animation effect. Setwhen (System.currenttimemillis ())//notification of the time generated, will be displayed in the notification information, generally is the system acquired SetPriority (Notification.priority_default)//Set this notification priority//. Setautocancel (TRUE)//Set this flag when the user clicks the panel to let Notifications are automatically canceled. setongoing (false)//ture, set him as an in-progress notification. They are usually used to denote a background task where the user is actively involved (such as playing music) or is waiting in some way, thus occupying the device (such as a file download, synchronous operation, active network connection). SetDefaults (Notification.defau Lt_vibrate)//The simplest and most consistent way to add sound, strobe, and vibration effects to notifications is to use the current user default settings, using the Defaults property, which can be combined//notification.default_all N Otification. Default_sound add sound//requires vibrate permission. Setsmallicon (r.drawabLe.ic_launcher);//settings Notification small icon Intent Intent = new Intent (demo10activity.this,demo9activity.class); Pendingintent pendingintent = pendingintent.getactivity (demo10activity.this, 0, intent, 0); Mbuilder.setcontentintent (pendingintent); Notification Notification = Mbuilder.build (); Notification.flags = Notification.flag_auto_cancel; Manager.notify (1,notification);
Android Local Notifications