为手机应用配置表盘推送
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
对于规范市场,手机应用是用户与应用互动的主要方式。
设置表盘
当用户在手机应用中选择表盘时,后续设置表盘的流程分为两部分:
- 安装:使用通过
MessageClient
启动的表盘推送功能安装表盘。此步骤非常简单,可以使用 addWatchFace
或 updateWatchFace
,通过手机上的 MessageClient
触发。
- 激活: 将已安装的表盘主题设为当前表盘主题。此步骤有多种可能的路径,具体取决于权限状态:
- 您可能无需执行任何操作。应用商店可能已控制当前表盘主题。
- 无需用户干预。应用拥有设置有效表盘主题的必要权限,可以直接使用
setWatchFaceAsActive()
进行设置。
- 可能需要提供指导,说明如何接受权限请求,或者如何使用长按手势或通过配套应用手动设置表盘主题。
安装响应
为了方便 激活阶段,安装阶段应将以下信息从手表返回到手机:
- 安装尝试的结果
isWatchFaceActive()
的结果 - 用于确定应用是否已拥有当前表盘。
setWatchFaceAsActive()
是否已在过去被调用过 - Wear OS 应用应在本地跟踪并持久保存此信息。此 API 调用只能使用一次。
启用
安装完成后,响应可能会表明应用已具有有效的表盘。不过,如果不支持,应用可以选择显示一个用于将表盘主题设为当前表盘主题的按钮。
情形 1:设置当前表盘主题的所有尝试均已用尽
如果安装的响应表明之前已调用过 setWatchFaceAsActive()
,则该按钮应引导用户前往手机上的指导界面,向用户展示如何触摸并按住表盘,以手动将其设置为所需的主题。
场景 2 - 尝试设置当前表盘主题
手机应指示手表检查必要的 SET_PUSHED_WATCH_FACE_AS_ACTIVE
权限:
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-29。
[null,null,["最后更新时间 (UTC):2025-08-29。"],[],[],null,["# Configure your phone app for Watch Face Push\n\nFor the canonical marketplace, the phone app is the predominant way in which\nthe user interacts with the app.\n\nSet a watch face\n----------------\n\nWhen the user selects a watch face in the phone app, there are two parts to the\nsubsequent flow to set the watch face:\n\n1. **Installation:** Install the watch face using Watch Face Push, initiated through `MessageClient`. This step is straightforward, using either `addWatchFace` or `updateWatchFace`, triggered using `MessageClient` from the phone to the watch.\n2. **Activation:** [Set the installed watch face as active](/training/wearables/watch-face-push/wear-os-app#set-watch-face-as-active). This step has several possible paths, depending on the permission state:\n - There may be **no action needed**. The marketplace may already have control of the active watch face.\n - There may be **no user intervention needed** . The app has the necessary permissions to set the active watch face, and can do so directly using `setWatchFaceAsActive()`.\n - There may be **guidance needed**, either as to how to accept permission requests, or how to manually set the watch face using a long-press gesture or through a companion app.\n\nInstallation response\n---------------------\n\nTo facilitate the **Activation** phase, the **Installation** phase should return\nthe following information from the watch to the phone:\n\n- The outcome of the installation attempt\n- The result of `isWatchFaceActive()` - to determine whether the app already has the active watch face.\n- Whether `setWatchFaceAsActive()` has already been called in the past - the Wear OS app should track and persist this information locally. *This API\n call can only be used once.*\n\nActivation\n----------\n\nFollowing the installation, the response may indicate that the app already has\nthe active watch face. However if it does not, then the app may choose to show a\nbutton to **set watch face as active**.\n\n### Scenario 1: All attempts to set the active watch face are exhausted\n\nIf the response from installation indicated that `setWatchFaceAsActive()` had\nalready been called in the past, then the button should lead to an education\nscreen on the phone, showing the user how to touch \\& hold on the watch face to\nmanually set it to the one they want.\n\n### Scenario 2 - Try to set the active watch face\n\nThe phone should instruct the watch to check for the necessary\n`SET_PUSHED_WATCH_FACE_AS_ACTIVE` permission:\n\n- If the user has **already granted it**, proceed to calling setWatchFaceAsActive().\n- If the user has **previously denied the permission**, the watch should communicate this back to the phone, where an education screen can be shown explaining the need for the permission and how to manually grant it.\n- If the **permission has not been requested before**, the watch should\n instruct the phone to show an educational moment guiding the user on how to\n accept permissions on the watch, and the watch should proceed to request the\n permission.\n\n - If the user grants the permission, the watch should then call `setWatchFaceAsActive()`.\n - Otherwise the watch should instruct the phone to show an education screen explaining the need for the permission and how to manually grant it."]]