Detailed explanation of notification notification usage in Android
Role of notification
Notification is a feature of Android system. When an application wants to send some prompt information to the user, and the application is not running in the foreground, it can be realized by notification
usage
First, we need a notificationmanager to manage notifications. We can call the getsystemservice () method. The method receives a string parameter to determine which service to obtain from the system. Here we pass in notification_ SERVICE。
Next, a builder constructor is used to create the notification object
matters needing attention
After the notification attribute is defined, the notification is displayed through the notify () method of the notificationmanager object. If the notification cannot be sent after the project is running, please see "notification management" in the "notification and status bar" in the mobile phone. Some mobile phones do not allow notifications to apps by default, so you need to open the permission notification before running the project to receive the notification information.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.