Android Study Notes (32): Notification push Analysis

Source: Internet
Author: User

Android Study Notes (32): Notification push Analysis

Notification is used to display notifications in the mobile phone status bar. Generally, notifications are sent through the icationicationmanager service.

The Notification. Builder class makes it easier for us to create Notification objects.

 

Common Notification. Builder methods:

SetAutoCancel (): sets the notification to be clicked, And the status bar automatically deletes the notification.

SetContentText (): Set the notification content

SetContentTitle (): Set the notification title

SetContentIntent (): Set the PendingIntent corresponding to the program component to be started after clicking

SetDefaults (): Set the notification LED light, music, vibration, etc.

SetLargeIcon (): Set the big icon

SetSmallIcon (): Set the small icon

SetTicker (): Set the prompt text of the notification in the status bar.

 

To send a Notification, follow these steps:

1. Call the getSystemService (icationication_service) method to obtain the NotificationManage service.

2. Create a Notification object with the constructor.

3. Set various attributes for Notification.

4. send Notification through icationicationmanager.

 

The setDefault () method can set the following attributes:

DEFAULT_SOUND: Set the default sound

DEFAULT_VIBRATE: Set to use default Vibration

DEFAULT_LIGHTS: Set to use the default flashlight

ALL: set the above three types to default

 

Of course, you can also use setSound (), setVibrate (), and other methods to set your desired attributes.

 

At last, we need to add the corresponding permissions to the AndroidManifest. xml file.

 

Related Article

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.