Notification bar, dialog box,Toast is our contact three prompts box, the notification bar is in the system application com.adnroid.systemui
Contact with several Manger,getsystemservice () method obtained, parameters:
Activity_service,Layout_inflater_servic,telephony_service,
Gets the notificationmanager object, through the getsystemservice () method, Parameter:notification_service
Call the notify () method of the notificationmanager object , send a notification, parameter:ID is 0 , theNotification Object
Get Builder object, via new Notification.builder ()
Call the Builder object's setcontenttitle () setcontenttext () Setsmallicon () Setlargeicon ()
Setlargeicon Parameters:Bitmap object,bitmapfactory.decoderesource (), Parameters: Getresoure (), resource ID
Call the build () method of the Builder object to get the Notification Object
Some errors will be reported at this time, the minimum compatible version is one, we directly add a comment to screen out the error "Newapi"
On the lower version of the phone, the above code will go wrong
Get Notification object, through new , Parameters: Resource ID, text, Time
Call the Setlasteventinfo () method of the Notification Object , set the latest message, Parameters: Context, text,pendingintent Object
Set the flags Property of the Notification object to notification.flag_auto_cancel auto-close
The Pendingintent object, through the pendingintent getactivity () method , Get to pendingintent Object
6.0 version removed Notification.setlatesteventinfo () method
Rogue software will use this to play ads, we can enter the system application settings, tick off the display notification
[Android] notification Getting Started