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