Android 8.0 icationicationchannel mining example,
New Notification features on Android O: Notification channel function 1. introduction: The notification channel function enables developers to manage notifications of their applications as a group or channel. Users can set notifications through the notification channel, such as blocking all notifications, change the priority of a channel notification to see whether the dots on the launch are displayed. These methods are used to improve the user experience. 2. 1. Step 1: Upgrade the sdk version. The minsdkversion developed using android studio cannot be less than 26. Otherwise, the new features cannot be used. 2. Part 2: Create a project. It is best to put icationicationchannel in util and encapsulate it into a separate class for management. From the analysis of android intent, notifications of each application must be managed, including the priority of notifications, which must be centrally managed through channels, you can create important_high/importan_default/importan_minor/importan_low channels. Method for creating a channel: // instantiate a channel object icationicationchannel androidChannel = new icationicationchannel (ANDROID_CHANNEL_ID, ANDROID_CHANNEL_NAME, icationicationmanager. IMPORTANCE_DEFAULT); ANDROID_CHANNEL_ID: the channel id ANDROID_CHANNEL_NAME: the channel name (this name is very important, and the channel name specified when the notification is sent later). The last parameter is: priority of notifications for this channel // create a channel icationicationmanager. createNotificationChannel (androidChannel); 3. create a new notification and send it out // use the new interface to create a builder object, specifying the channel builder of the notification = New Notification. builder (getApplicationContext (), ANDROID_CHANNEL_NAME/* channel name */) // sends a notification to icationicationmanager. notify (id, builder. build () In addition: micationicationmanager. createNotificationChannelGroup (new NotificationChannelGroup (groupId, groupName); this interface is also very interesting.
For apps with multiple users, such as some social applications with work accounts and private accounts, all the channels under different users can be defined as a group for management.