[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-11。"],[],[],null,["# Conversation notifications and widgets\n\nAndroid 11 adds support for customizing the behavior\nand placement of Conversation Notifications on the Notifications shade by\npriority and alerting level, allowing Conversations to be marked as Important\nand conversation specific [bubbles](https://developer.android.com/guide/topics/ui/bubbles)\nto be launched in the Conversation space.\n\nBuilding on these Android 11 features,\nAndroid 12 offers two new Conversation features:\n\n- The Recent Conversations feature in Settings enables users to customize\n notification behavior for recent conversations without waiting for a notification.\n\n- The Conversation Widget feature enables users to easily open chats on the\n home screen, giving a quick view of recent conversations.\n\nThis document describes the implementation, customization and validation aspects\nof conversation notifications and widgets.\n\nConversation Notifications overview\n-----------------------------------\n\nAndroid 11 introduces a new system primitive, the\nConversation, that is represented by the existing [sharing shortcut object](https://developer.android.com/reference/android/content/pm/ShortcutInfo)\n(which was rolled out with Android 9).\n\nThe Conversations primitive can be used as follows:\n\n- To share Conversations data between the apps across the system through\n [Sharesheet](https://developer.android.com/training/sharing/send) (already in Android 10).\n\n- For driving [bubbles](https://developer.android.com/guide/topics/ui/bubbles)([shortcuts](https://developer.android.com/reference/kotlin/android/app/Notification.BubbleMetadata.Builder#Builder(kotlin.String))\n in Android 11).\n See [Figure 1](#conv-figure1).\n\n- To participate in the new Conversation space on top of the Notification\n shade (implemented in Android 11). See\n [Figure 2](#conv-figure2).\n\n- For creating [Conversation Widgets](#widgets-overview) (implemented in Android 12).\n\n **Figure 1:** Notification being launched as a bubble from the notification drawer\n\n **Figure 2:** Conversation space located on top of the Notification shade\n\nBesides linking to the shortcut representing the conversation, the notification\nalso uses [MessagingStyle](https://developer.android.com/reference/android/app/Notification.MessagingStyle)\nto include the last message of the conversation in the Conversation space.\n\nGMS partners are required to implement the following:\n\n- A new Conversations space as a separate section on top of the Notification shade.\n- A notification style that allows and supports the Conversation specific bubble pattern.\n\n| **Note:** Implementation of the Conversation space and support for Conversation specific bubbles is strongly recommended for all Android devices.\n\nPartners that implement Conversations are required to implement Important\nconversations as well. However, implementation of Conversations can be aligned\nwith OEM concepts of similar nature. Overall, partners have the freedom to align\nthe conversation section with their specific System UI. The partner does not have to modify or implement HAL/driver/kernel code/extensions.\n| **Note:** The Conversation Notifications feature is in AOSP, is CTS compatible and does not require any GMS integration. The feature can't be turned on or off.\n\nSee the following reference implementation in the SystemUI \\& PeopleService\nsections in AOSP: \n\n frameworks/base/packages/SystemUI/src/com/android/systemui/people/\n frameworks/base/core/java/android/app/people/\n frameworks/base/services/people/java/com/android/server/people/\n\n### Validation\n\nTo ensure that your version of the feature works as intended, verify the\nfollowing:\n\n1. Apps that fully support the Conversation API see their notifications in the\n new section, and can customize those notifications by conversation rather than\n by the generic [NotificationChannel](https://developer.android.com/reference/kotlin/android/app/NotificationChannel).\n\n2. Conversation specific bubbles are working.\n\nTo validate the implementation, use the following tests in the notification\npackage:\n\n- CTS tests.\n\n cts/tests/app/src/android/app/cts/NotificationManagerTest.java\n\n- CTS Verifier tests.\n\n cts/apps/CtsVerifier/src/com/android/cts/verifier/notifications/\n\nConversation Widgets overview\n-----------------------------\n\nIn Android 12, the Conversation Widget feature builds\non the Conversation representations created in Android 11\n(as the preceding section describes) by allowing apps to provide status for\nthose conversations which are displayed in Conversation Widgets.\n\n**Figure 3:** Conversations displayed in Conversation Widgets\n\nThe Conversation Widget feature in Android 12 promotes\nconnection by allowing users to easily open chats on the home screen. The\nwidgets are enhanced shortcuts that allow users to efficiently get back to their\nconversations while showing snippets of the conversation statuses.\n| **Note:** This feature is purely in AOSP. OEMs do not need to integrate any closed source Google components to make this feature work.\n\nThe partner must implement the following:\n\n1. A widget provided by SystemUI.\n2. A flow to add these widgets from the widget picking screen.\n3. Support for widget resizing as follows:\n - Use [`onAppWidgetOptionsChanged()`](https://developer.android.com/reference/android/appwidget/AppWidgetProvider) to change the layout to a better sized layout when the user changes the Layout Size or rotates to landscape.\n - Use [`maxResizeHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#maxResizeHeight), [`maxResizeWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#maxResizeWidth), [`minWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minWidth), [`minHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minHeight), [`minResizeWidth`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minResizeWidth), [`minResizeHeight`](https://developer.android.com/reference/android/appwidget/AppWidgetProviderInfo#minResizeHeight) to correctly bound your widget size changes.\n\nBe aware of the following dependencies when implementing Conversation Widgets:\n\n- The partner does not have to modify or implement HAL/driver/kernel code.\n- The Status API, which allows apps to add status or availability information to a conversation and the associated widget, is used for implementation.\n- The process is the same on both new device implementations and upgrade implementation.\n- The Conversation Widgets feature has a dependency on a new feature launching in Android 12, which caches recently seen conversations (from notifications, for example). This latter feature allows to expand the list of conversations a user could potentially add to their home screen.\n\nSee the following reference implementation in SystemUI and Launcher3 files: \n\n frameworks/base/packages/SystemUI/src/com/android/systemui/people/\n frameworks/base/core/java/android/app/people/\n frameworks/base/services/people/java/com/android/server/people/\n\n### Customization\n\nThe Conversation Widgets feature can't be turned on or off. However, a partner\ncan change the layouts of the widget templates, as long as GMS requirements are\nsatisfied.\n\n### Validation\n\nTo ensure that your version of the feature works as intended, verify the\nfollowing:\n\n1. On a long-press on Launcher, a new Conversation Widget for a Conversation\n can be added through the widget picker. See figure 4 for the Widget picker UI:\n\n **Figure 4:** Widget picker UI to add a new Conversation Widget\n2. On sending notifications to the device from the selected Conversation, the\n widget is updated to reflect those notifications.\n\n3. On applying statuses to that Conversation using the\n [`ConversationStatus`](https://developer.android.com/reference/kotlin/android/app/people/ConversationStatus)\n API, the widget reflects those statuses.\n\n4. Users can resize widgets and widgets can change their sizes based on their\n current Launcher. Your widget layouts must work well with different Launcher\n sizes on different devices and on resizing the widget.\n\nTo validate the implementation, use the following tests in the notification\npackage:\n\n- CTS tests (PeopleManagerTest) for the API surfaces.\n\n cts/tests/app/src/android/app/cts/NotificationManagerTest.java\n\n- Manual tests for GMS requirement - Conversations."]]