Android Notification bar notification simple but use, effect like, nonsense don't say, code:
1 Private voidnotification () {2 Notification Notification;3 intnotification_id = 11;4 5 //getting objects through system services6Notificationmanager Notificationmanager =(Notificationmanager) Getsystemservice (notification_service);7 //Create a Notification object8Notification.builder Nbuider =NewNotification.builder (mainactivity. This);9 //the effect of setting notification is the default effectTen nbuider.setdefaults (notification.default_lights); One //set the text that notification appears in the status bar for the first time ANbuider.setticker ("Tell you to go on a business trip!" "); - //title -Nbuider.setcontenttitle ("Notifications"); the //Small title -Nbuider.setcontenttitle ("That's it."); - //Small title -Nbuider.setcontenttext ("Good"); + //delay 0ms, then vibrate 500ms, delay 300ms, then vibrate 350ms. -Nbuider.setvibrate (New Long[]{0,500,300,350}); +Nbuider.setsmallicon (R.DRAWABLE.E);//Do not set the icon does not come out, do not know what the situation A at //Create a intent pair image, as a pendingintent parameter -Intent Intent =NewIntent (mainactivity. This, Animationactivity.class); - //activity associated with the Pendingintent object -pendingintent pi = pendingintent.getactivity (mainactivity. This, 0,intent,0); - - in //Open Trigger - nbuider.setcontentintent (pi); to + //Create a notification -Notification =nbuider.build ();//API 16 or more to use theNotification.flags |= Notification.flag_auto_cancel;//The original text icon disappears after clicking the notification * //Send Notifications $ notificationmanager.notify (notification_id,notification);Panax Notoginseng}
ANDROID Notification Notification