创建以进度为中心的通知

以进度为中心的通知
图 1. 遮罩顶部的以进度为中心的通知。

Android 16 引入了一种新的通知模板,可帮助用户顺畅地跟踪用户发起的端到端历程。这些通知在系统界面上的曝光度将得到提升,并在通知抽屉中获得最高排名。

使用 Notification.ProgressStyle 为以进度为中心的通知设置样式。主要用例包括共享车辆、送货和导航。在该类中,您可以使用“点”和“线段”来表示用户体验历程中的状态和里程碑。

相关类

以下类包含用于构建 ProgressStyle 通知的不同 API:

结构和自定义

以下图片显示了构成 ProgressStyle 通知的不同部分:

图 2.ProgressStyle notification. 的不同部分
Figure 3. Apps can set a vehicle image for the tracker icon and use segments and points to denote the rideshare experience and milestones.

Set up

Use the right APIs and follow best practices to provide the best user experience for progress updates.

  • Set the right fields to meet promoted visibility.
  • Use the right visual elements to guide users. For example, rideshare apps should set a vehicle image and use the most accurate color of the vehicle in the notification using Notification#setLargeIcon.
  • Use concise and clear language to define the progress of the user journey. Time of arrival, driver name, and state of the journey are important text that the notification should communicate.
  • Provide useful and relevant actions in the notification that streamline the user journey. For example, providing "Tip" and "Add dish" to a newly initiated food delivery order are useful actions before delivery.
  • Use segments and points to denote states. For example, segments can colorize the state and duration of traffic in a rideshare journey. Points represent states for milestones such as food preparation, delivery, and passenger pickup.
  • Update the progress experience to accurately reflect the actual progression of the journey. For example, changes in traffic conditions can be reflected in changes in segment colors and updates in text.

The following example shows a ProgressStyle notification for a rideshare app.

The example shows the use of a vehicle image for the tracker icon. It also shows the use of segments and points to denote the rideshare experience and milestones.

See the sample app to experiment with these APIs.