Notifications provide brief, timely, and relevant information related to your app when it's not in use. Show
The Android OS controls many aspects of notifications, but you have control over other aspects. Follow these steps when implementing notifications:
Takeaways
Anatomy of a notificationNotifications are designed to make it easy to scan and use a notification's most important elements. These elements are:
When collapsed, a notification shows the app icon, header text, timestamp, expand indicator, and content text. It can also optionally show a large icon. 1 App icon: The app icon is a two-dimensional representation of your app's identity. It appears in monochrome in the status bar. If your app sends a wide variety of notifications, consider replacing your app icon with a symbol to distinguish between the different kinds of notifications. See for details. 2 Header text: a brief headline for the notification or source, such as the account name for users. Content is the most prominent element of a notification. 3 Timestamp: indicates when a notification was sent, such as the time of a missed call. 4 Expand indicator: indicates whether the notification is in a collapsed or expanded state. 5 Content text: supporting information. 6 Large icon (optional): An image may be added to reinforce the notification in a meaningful way, such as a message that includes an avatar of the sender. Apply the icon colorStarting in Android 12 (API level 31), the system derives the icon color from the notification color you set in the app. If the app doesn't set the color, it uses the system theme color. Previously, the color was gray. For most styles, the system applies this color only if the notification is for a foreground service notification. However, there is no such requirement for The following snippet shows how to apply the icon color.
Notification actions1 Text button actions 2 Filled action buttons 3 Suggested replies 4 Reply text field Starting with Android 7.0 (API level 24), the system shows actions without icons to accommodate more text. To accommodate Android Wear devices and devices running Android 6.0 (API level 23) and lower, your app must still provide an icon. Expanded viewsYou can use an expanded view to display more information to the user without navigating away from the notification. When expanded, a notification can provide up to three of any of the following kinds of actions:
Don'tInclude text actions that duplicate the behavior of tapping on the notification body. DoGive the user a chance to interact with the notification. The Google Clock app shows a timer running, but it lets the user pause or add a minute directly from the notification. Enable typing in notificationsYou enable the user to type directly into a notification by including a Reply action. This is designed for typing a small amount of text, such as replying to a text message or jotting a brief note. For longer-form typing, navigate users to your app to provide them more space to view and edit text. For messaging apps, we recommend keeping the notification present after the user has sent the reply, and waiting until the conversation is paused before automatically dismissing it. Choose the notification type depending on your use caseGoogle uses the following notification templates in its Android apps. These templates can be customized to some extent for your app. Check out the Android UI Kit on Figma for notification templates. Standard templateThe standard template is suitable for most notifications, allowing succinct text, a large icon (when applicable), and actions. Big text templateThe big text template is ideal for displaying blocks of longer text. It lets the user preview more text after they expand the notification. Big picture templateThe big picture template is designed for notifications containing an image. When collapsed, the notification shows a large icon thumbnail of the picture. When expanded, the notification shows a much larger preview. Progress templateThe progress template is designed for user-initiated activities that take time to complete. When expanded, a notification that uses this template shows a progress bar and also includes a "cancel" action that lets the user terminate this activity. (Non-cancelable activities don't warrant notifications.) Media templateThe media template is designed for letting the user control media currently playing from an app.
Messaging templateThe template is designed for real-time communication. When expanded, a notification using this template lets the user reply to messages from within the notification. Call templateUse the CallStyle template to generate large-format notifications that include a large image attachment and indicate an incoming or outgoing call. Notification permissionsAs relevant and timely as notifications can be, most notifications are non-exempt, that is, the user must consent to receiving notifications from your app. There is one exception to this: starting in Android 13 (API level 33), media sessions and apps that manage phone calls are exempt from asking for user consent. Pre-existing apps may also be eligible if the user already has notifications on. See more details in . We strongly recommend that your app provide notification options in settings to allow users to update their notifications preferences. Prompt the user to opt-in to non-exempt notificationsFor non-exempt notifications, prompt the user to indicate whether they want to to opt-in to receiving notifications. Users who explicitly choose to receive notifications are likely to find them more useful and less intrusive. Wait to show the notification dialog prompt:
Starting in Android 13, users can be re-prompted for notification permissions. Required notificationsForeground services perform operations that are noticeable to the user but while they're not directly interacting with your app. These services show a status bar notification to make users aware that your app is performing a task in the foreground and is consuming system resources. Because these processes use battery and possibly data, your app must make users aware of them by showing a non-dismissible notification. The user can't dismiss the notification, so you must provide an action for the user to stop the service. The following example shows a notification from a fitness app. The user has started an active workout session, which instantiates a foreground service tracking the workout session. The app shows the notification to indicate it's tracking walking, with an option to see the workout. When not to use a notificationDon't use notifications for any of the following use cases:
Don'tSend holiday or birthday greetings in the form of notifications. Don'tInterrupt the user in the middle of a task for the sole purpose of asking if you're doing a good job. BehaviorBe aware of the following notification behaviors and how to handle them in certain contexts. Notification arrivalWhen a notification arrives, Android adds it to the notification drawer. Depending on the parameters you set and the current state of the device, the notification may perform any of the following actions:
As always, the user can choose to alter the notification behaviors you set. 1 Notification indicator in the status bar, indicating that there's a notification in the notification drawer. 2 Notification "peeking" onto the current screen to grab a user's attention in the middle of a task. Notification drawerThe notification drawer in Android typically shows notifications in reverse-chronological order, with adjustments influenced by the following conditions:
Handle stale notifications The notification drawer is designed to show users information that is relevant for the current moment in time. If an earlier notification is stale, that is, no longer relevant, dismiss it so the user doesn't see it. New notifications indicated by app icon badgeIn supported launchers on devices running Android 8.0 (API level 26) and higher, app icons display a notification dot to indicate that the app has a new notification associated with it. These dots appear by default in launcher apps that support them, and there's nothing your app needs to do. Badging can also be disabled and limited. Actions users can perform with notificationsNotifications can enable users to perform any of the following actions:
Ongoing notifications that indicate a continuing process in the background, such as music playing, may not be dismissed with a swipe.
The controls displayed vary depending on the Android version and whether the app has channels for its notifications (starting in Android 8.0). Group multiple notificationsFor apps that generate multiple notifications of the same type, Android offers notification grouping to avoid overwhelming users. Your app can present multiple notifications according to the following hierarchy.
Android presents child notifications without duplicate header information. For example, if a child notification has the same app icon as its parent, the child's header doesn't include an icon. Child notifications must be understandable if they appear solo, as the system may show them outside of the group when they arrive. SettingsChannelsStarting in Android 8.0 (API level 26), all notifications must be assigned to a channel. For each channel, you can set the visual and auditory behavior that is applied to all notifications in that channel. Users can change these settings and decide which notification channels from your app can be intrusive or visible. For details on how to implement this, see Create and manage notification channels. Importance should be chosen with consideration for the user's time and attention. When an unimportant notification is disguised as urgent, it can produce unnecessary alarm. Importance Behavior Usage Examples`HIGH` Makes a sound and appears on screen Time-critical information that the user must know, or act on, immediately Text messages, alarms, phone calls`DEFAULT` Makes a sound Information that should be seen at the user’s earliest convenience, but not interrupt what they're doing Traffic alerts, task reminders`LOW` No sound Notification channels that don't meet the requirements of other importance levels New content the user has subscribed to, social network invitations`MIN` No sound or visual interruption Non-essential information that can wait or isn’t specifically relevant to the user Nearby places of interest, weather, promotional content Pre-defined categoriesWhether you're using channels or not, assign each individual notification to the most suitable predefined category. Android may use this information to make ranking and filtering decisions. Category Description`CATEGORY_CALL` Incoming call (voice or video) or similar synchronous communication request`CATEGORY_MESSAGE` Incoming direct message (SMS, instant message, etc.) Lock screen notificationsIf a user has opted to show notifications when their screen is locked, these notifications can conceal any content that your app marks as sensitive. Android evaluates each notification's visibility level to determine what can safely be shown. Set sensitivity level for content on lock screensUser privacy is critically important, so be aware that there are different levels of notification that can be visible on the lock screen. For each notification you create, you must set the visibility level to public, private, or secret.
In the following example, lock screen notifications for the Gmail and Photos apps show all content after the user has chosen to show this information on the lock screen. 1 All notification content shown on the lock screen 2 Sensitive notification content hidden on the lock screen StyleClear and concise textAndroid truncates content titles to a single line (even when expanded). A good content title adheres to the following guidelines:
Don'tShow the app name in the content title, which is redundant with the header area and uses available characters. DoShow the most important information in the content title. Good content text adheres to the following guidelines:
The large iconUse the large icon for use cases in which imagery meaningfully reinforces the notification's content. Some examples are:
Large icons must be circular when showing a person, but square in all other cases. Don'tUse the large icon for branding. DoUse the large icon to reinforce a notification's content in a meaningful way, such as a displaying person's photo attached to a message notification. Android version updatesThe Android notification system UI and the notification-related APIs continually evolve. For a list of these changes check out the . Platform ConsiderationsWearIf the user has a paired Wear OS device, all your notifications appear there automatically, including expandable detail and action buttons. For details, see the . How to make notifications appear on top on Android?Option 1: In your Settings app. Open your phone's Settings app.. Tap Apps & notifications. Notifications.. Under “Recently Sent,” tap an app.. Tap a type of notification.. Choose your options: Choose Alerting or Silent. To see a banner for alerting notifications when your phone is unlocked, turn on Pop on screen.. How do I pin notifications to the top of my Android phone?Go to Settings > Notifications & status bar , locate and touch the app for which you wish to pin notifications, and enable Pin to top.nullPin App Notifications to the Top | HUAWEI Support Globalconsumer.huawei.com › support › content › en-us15961873null What is the notification bar on top of screen?The notification bar is the black bar at the top of your screen and will show you notifications, like incoming text messages, missed phone calls, or the current weather. Go to "Settings > Lock Screen" and tap the toggle to enable notifications so you see notifications on your Lock Screen.7 thg 5, 2024nullHow to Enable the Notification Bar on an Android: 2 Easy Wayswww.wikihow.com › ... › Telephones › Smartphones › Androidnull |