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.