Notifications
In Android 8.0 (API level 26), we've redesigned notifications to provide an easier and more consistent way to manage notification behavior and settings. These changes include:
- Notification channels: Android 8.0 introduces notification channels that allow you to create a user-customizable channel for each type of notification you want to display. The user interface refers to notification channels as notification categories. To learn how to implement notification channels, see Managing notification channels.
- Notification dots: Android 8.0 introduces support for displaying dots, or badges, on app launcher icons. Notification dots reflect the presence of notifications that the user has not yet dismissed or acted on. To learn how to work with notification dots, see Notification badges.
- Snoozing: Users can snooze notifications, which causes them to disappear for a period of time before reappearing. Notifications reappear with the same level of importance they first appeared with. Apps can remove or update a snoozed notification, but updating a snoozed notification does not cause it to reappear.
- Notification timeouts: You can set a timeout when creating a notification using
setTimeoutAfter()
. You can use this method to specify a duration after which a notification should be canceled. If required, you can cancel a notification before the specified timeout duration elapses. - Notification settings: You can call
setSettingsText()
to set the text that appears when you create a link to your app's notification settings from a notification using theNotification.INTENT_CATEGORY_NOTIFICATION_PREFERENCES
intent. The system may provide the following extras with the intent to filter the settings your app must display to users:EXTRA_CHANNEL_ID
,NOTIFICATION_TAG
, andNOTIFICATION_ID
. - Notification dismissal: Users can dismiss notifications themselves, and apps can remove them programmatically. You can determine when a notification is dismissed and why it's dismissed by implementing the
onNotificationRemoved()
method from theNotificationListenerService
class. - Background colors: You can set and enable a background color for a notification. You should only use this feature in notifications for ongoing tasks which are critical for a user to see at a glance. For example, you could set a background color for notifications related to driving directions, or a phone call in progress. You can also set the desired background color using
setColor()
. Doing so allows you to usesetColorized()
to enable the use of a background color for a notification. - Messaging style: In Android 8.0, notifications that use the
MessagingStyle
class display more content in their collapsed form. You should use theMessagingStyle
class for notifications that are messaging-related. You can also use theaddHistoricMessage()
method to provide context to a conversation by adding historic messages to messaging-related notifications.
No comments:
Post a Comment