[Android] notification Getting Started

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.