Progress-centric notifications (original) (raw)

Android 16 introduces progress-centric notifications to help users seamlessly track user-initiated, start-to-end journeys.

Notification.ProgressStyle is a new notification style that lets you create progress-centric notifications. Key use cases include rideshare, delivery, and navigation. Within the Notification.ProgressStyleclass, you can denote states and milestones in a user journey usingpoints and segments.

A progress-centric notification displayed on the lockscreen.

A progress-centric notification displayed in the notification shade.

Relevant classes and methods

The following classes contain the different APIs that you use to construct aProgressStyle notification:

Anatomy and customization

The following images show the different parts that make up ProgressStylenotifications:

The following images show the different parts that make up ProgressStylenotifications:

A. Header - Subtext Notification.Builder.setSubText()
B. Header - Time Notification.Builder.setWhen()
C. Content Title Notification.Builder.setContentTitle()
D. Content Text Notification.Builder.setContentText()
E. Progress bar Notification.ProgressStyle
F. Action button Notification.Builder.addAction()

Apps can set a vehicle image for the tracker icon and use segments and points to denote the rideshare experience and milestones.

Best practices

Adhere to the following best practices to help provide the best possible user experience with progress-centric notifications:

The following code snippet shows how a ProgressStyle notification could be used for a rideshare context:

var ps =
    Notification.ProgressStyle()
        .setStyledByProgress(false)
        .setProgress(456)
        .setProgressTrackerIcon(Icon.createWithResource(appContext, R.drawable.ic_car_red))
        .setProgressSegments(
            listOf(
                Notification.ProgressStyle.Segment(41).setColor(Color.BLACK),
                Notification.ProgressStyle.Segment(552).setColor(Color.YELLOW),
                Notification.ProgressStyle.Segment(253).setColor(Color.WHITE),
                Notification.ProgressStyle.Segment(94).setColor(Color.BLUE)
            )
        )
        .setProgressPoints(
            listOf(
                Notification.ProgressStyle.Point(60).setColor(Color.RED),
                Notification.ProgressStyle.Point(560).setColor(Color.GREEN)
            )
        )

Note that in the example, a vehicle image is set for the tracker icon, and segments and points are used to denote the rideshare experience and milestones to provide a more complete user experience.

Check out the sample app for more information.