public class Notificationtest extends activity{static final int notification_id = 0x1123; @Overridepublic void OnCreate (Bu Ndle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (r.layout.main);// Gets the button object in the App interface button bn = (Button) Findviewbyid (r.id.bn);//Event listener Bn.setonclicklistener for the buttons ' click event (new View.onclicklistener () {@Overridepublic void OnClick (View source) {//Creates a intentintent intent = new intent that initiates other activity ( Notificationtest.this, Otheractivity.class); pendingintent pi = pendingintent.getactivity (notificationtest.this, 0, intent, 0);//Create a Notificationnotification notify = new Notification ();//Set the icon for Notification, which is displayed in the status bar Notify.icon = r.drawable.notify;//Sets the text content for Notification, The text is displayed in the status bar Notify.tickertext = "Start other activity notifications";//Set send time for notification Notify.when = System.currenttimemillis ();// Set the sound for Notification notify.defaults = notification.default_sound;//Set default sound for Notification, default vibration, default Flash notify.defaults = notification.default_all;//Setting Event information Notify.setlatesteventinfo (notificationtest. This, "General notice", "Click to view", pi);//Get the system's Notificationmanager service Notificationmanager Notificationmanager = ( Notificationmanager) Getsystemservice (notification_service);//Send notification notificationmanager.notify (NOTIFICATION_ID, notify);}); /Cancel notification Button del = (Button) Findviewbyid (R.id.del);d El.setonclicklistener (new Onclicklistener () {@Overridepublic void OnClick (View v) {//Get System Notificationmanager Service Notificationmanager Notificationmanager = (Notificationmanager) Getsystemservice (Notification_service);//cancellation Notice notificationmanager.cancel (notification_id);}});}}