Android Learning Note (32): Notification push notification

Source: Internet
Author: User

Notification is used to display notifications in the phone's status bar. notifications are generally sent through the notificationmanager service.

the Notification.builder class allows us to create Notification objects more conveniently.

Notification.builder Common methods:

Setautocancel (): Set the status bar to automatically delete notifications after clicking Notifications

Setcontenttext (): Set notification content

Setcontenttitle (): Set notification title

Setcontentintent (): Set the pendingintent of the program component to start after clicking

SetDefaults (): Set notification led lights, music, vibration, etc.

Setlargeicon (): Set Large icon

Setsmallicon (): Set small icon

Setticker (): Sets the prompt text of the notification in the status bar

steps to send Notification :

1. Call the getsystemservice (notification_service) method to get the notificationmanage service.

2. Create a Notification object with the constructor.

3. set various properties for Notification.

4. send Notificationvia notificationmanager .

the properties that can be set by the SetDefault () method are:

Default_sound: Set Use default sound

Default_vibrate: Set Use default vibration

Default_lights: Set Use default Flash

All: Set all of the above three defaults

Of course, we can also use setsound (),setvibrate () and other methods to set their own favorite properties.

Finally we have one more thing to do is to Add the appropriate permissions in the Androidmanifest.xml file.

Android Learning Note (32): Notification push notification

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.