Live Notifications and Now Bar in Samsung One UI 7: As developer
Live Notifications and Now Bar are new Samsung features available starting with One UI 7. This has sparked an idea for developers who want their apps to leverage these features. This article will explain the details of these features that developers should know.
TL;DR - Samsung has made these features available only to specific apps, so the content of this article cannot be used for actual implementation. It was written to fulfill my curiosity.
Understanding Live Notifications and Now Bar
These are Samsung features that make an app's ongoing notifications more prominent.
They can also be displayed in the Now Bar on the lock screen, allowing users to interact with or control those apps (e.g., stopwatches, YouTube, or Spotify).
However, there's a condition: these features are only designed for ongoing notifications from authorized apps or system functions. They are not intended for general apps.
Immediate Support for Media Playback
Apps with media playback that can run in the background will immediately support Live Notifications and Now Bar.
Developers can use MediaSessionService
from AndroidX Media3 to create media playback that instantly supports Live Notifications and Now Bar.
Support Only for Apps on Samsung's Whitelist
If you want to create an ongoing notification for a foreground service that supports Live Notifications and Now Bar, your app must be on Samsung's whitelist. Not all apps can use these features.
This whitelist is determined by the app's package name.
If your app is on the whitelist, you'll need to add specific code to enable the ongoing notification to support Live Notifications and Now Bar. Both features require separate code implementations.
Configuring Live Notifications and Now Bar
Your app must define metadata in the Android Manifest to inform One UI that your app has an ongoing notification that need to support Live Notifications and Now Bar.
<meta-data
android:name="com.samsung.android.support.ongoing_activity"
android:value="true" />
Configuration for displaying in Live Notifications and Now Bar involves sending data as a Bundle within the notification instance.
val extras = bundleOf(
// Required
"android.ongoingActivityNoti.style" to 1,
// Live Notifications & Now Bar configuration
)
val notification = NotificationCompat.Builder(/* ... */)
/* ... */
.setExtras(extras)
.build()
android.ongoingActivityNoti.style
must always be set to1
.
Live Notifications and Now Bar have different configuration values, and some Now Bar values can be set separately or use the same values as Live Notifications.
Configuring Live Notifications
The display of Live Notifications is divided into two parts.
First, Live Notifications will appear as a separate section from other notifications in the notification drawer.
Developers can define 3 display styles:
- Standard: Displays primary text and secondary text.
- Progress: Displays a progress bar.
- Custom: Displays a UI built from RemoteViews.
You can also set it to display 2-3 styles simultaneously.
For the standard style, the primary text must always be defined, while the secondary text is optional.
val context: Context = /* ... */
val extras = bundleOf(
/* ... */
// Required
"android.ongoingActivityNoti.primaryInfo" to "Akexorcist",
// Optional
"android.ongoingActivityNoti.secondaryInfo" to "Hello, Live Notifications",
// Optional
"android.ongoingActivityNoti.secondaryInfoIcon" to Icon.createWithResource(context, R.drawable.ic_celebration),
)
The other part of Live Notifications is called the chip, which appears as a bar in the top-left corner of the screen when the notification drawer is hidden.
Chip can only display an icon and text within a limited area. If these values are not defined, the values set in the notification drawer will be used automatically.
val context: Context = /* ... */
val extras = bundleOf(
/* ... */
// Optional
"android.ongoingActivityNoti.chipBgColor" to context.getColor(R.color.chip_background),
// Optional (default with notification's small icon)
"android.ongoingActivityNoti.chipIcon" to Icon.createWithResource(context, R.drawable.ic_chip_location)
// Optional (default with primary info)
"android.ongoingActivityNoti.chipExpandedText" to "Akexorcist"
)
Color definitions in the notification will not affect the display in Live Notifications. However, the color values defined in the chip will be used as part of the background color in the notification drawer, appearing as a gradient.
If action buttons are defined in the notification, Live Notifications must be configured to display them.
val extras = bundleOf(
/* ... */
"android.ongoingActivityNoti.actionType" to 1,
"android.ongoingActivityNoti.actionPrimarySet" to 0,
)
val pausePendingIntent: PendingIntent = /* ... */
val stopPendingIntent: PendingIntent = /* ... */
val notification = NotificationCompat.Builder(/* ... */)
/* ... */
.addAction(R.drawable.ic_notification_pause, "Pause", pausePendingIntent)
.addAction(R.drawable.ic_notification_stop, "Stop", stopPendingIntent)
.build()
For progress or custom display styles, these only affect the notification drawer and have no effect on the chip.
Progress Style Display
Progress style allows you to configure various progress values, such as:
val context: Context = /* ... */
val extras = bundleOf(
/* ... */
// Standard
"android.ongoingActivityNoti.primaryInfo" to "Akexorcist",
"android.ongoingActivityNoti.secondaryInfo" to "Hello, Live Notifications",
"android.ongoingActivityNoti.secondaryInfoIcon" to Icon.createWithResource(context, R.drawable.ic_celebration),
// Progress
"android.ongoingActivityNoti.progress" to 25,
"android.ongoingActivityNoti.progressMax" to 100,
"android.ongoingActivityNoti.progressSegments.icon" to Icon.createWithResource(context, R.drawable.ic_snowboarding),
"android.ongoingActivityNoti.progressSegments.progressColor" to context.getColor(R.color.progress_current),
"android.ongoingActivityNoti.progressSegments" to arrayOf(
bundleOf(
"android.ongoingActivityNoti.progressSegments.segmentStart" to 0.0f,
"android.ongoingActivityNoti.progressSegments.segmentColor" to context.getColor(R.color.progress_segment_1),
),
bundleOf(
"android.ongoingActivityNoti.progressSegments.segmentStart" to 0.0f,
"android.ongoingActivityNoti.progressSegments.segmentColor" to context.getColor(R.color.progress_segment_2),
),
)
Custom style display with RemoteViews
For a custom style, you'll need to create RemoteViews similar to those used in general notifications. You'll also need to define additional values for Live Notifications to display the RemoteViews, and you must define text for the chip.
val remoteViews: RemoteViews = /* ... */
val extras = bundleOf(
/* ... */
"android.ongoingActivityNoti.chronometerRemoteView" to remoteViews,
"android.ongoingActivityNoti.chronometerRemoteViewPosition" to 1,
"android.ongoingActivityNoti.chronometerRemoteViewTag" to "ongoing_remote_views_tag",
// Required for custom style
"android.ongoingActivityNoti.chipExpandedText" to "Akexorcist"
)
Custom style with RemoteViews will only replace the primary text section. Therefore, it can be displayed alongside secondary text and progress bar.
Configuring Now Bar
Now Bar uses some information from Live Notifications. Therefore, you'll only need to configure a few additional settings for the Now Bar.
val context: Context = /* ... */
val extras = bundleOf(
/* ... */
// Live Notifications
"android.ongoingActivityNoti.primaryInfo" to "Akexorcist",
"android.ongoingActivityNoti.secondaryInfo" to "Hello, Live Notifications",
// Now Bar
"android.ongoingActivityNoti.nowbarPrimaryInfo" to "Android"
"android.ongoingActivityNoti.nowbarSecondaryInfo" to "Hello, Now Bar"
)
Now Bar only supports standard style and custom style with RemoteViews. It does not support the progress style like Live Notifications.
For a custom style with RemoteViews, you'll need to add additional values for the Now Bar to ensure correct display.
val remoteViews: RemoteViews = /* ... */
val extras = bundleOf(
/* ... */
// Live Notifications
"android.ongoingActivityNoti.chronometerRemoteView" to bigRemoteViews,
"android.ongoingActivityNoti.chronometerRemoteViewPosition" to 1,
"android.ongoingActivityNoti.chronometerRemoteViewTag" to "ongoing_remote_views_tag",
// Now Bar
"android.ongoingActivityNoti.nowbarChronometerPosition" to 1,
)
Because the Now Bar has less display space than Live Notifications, the UI should be optimized for its smaller area.
Live Notifications and Now Bar will Support Live Updates in Android 16
Even though general apps cannot yet use the capabilities of Live Notifications and the Now Bar in One UI 7, with the advent of Live Updates on Android 16, Samsung has confirmed that in the next One UI version, these features will be automatically supported.
"Live Updates will work with Samsung's Now Bar, which appears on the lock screen, notifications screen, and in the status bar. Google is also working with OnePlus, OPPO, and Xiaomi to make this feature work on their phones." - SamMobile (Source)
This means that on One UI running Android 16 (expected to be One UI 8), developers will simply need to call the Android Platform API as usual to gain the capabilities of Live Notifications and Now Bar when their apps run on Samsung Android devices.