設定手機應用程式以便推送錶面
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
在標準市集中,使用者與應用程式互動的主要方式是透過電話應用程式。
設定錶面
使用者在手機應用程式中選取錶面後,後續設定錶面的流程分為兩個部分:
- 安裝:使用錶面推送功能安裝錶面,透過
MessageClient
啟動。這個步驟很簡單,只要使用 addWatchFace
或 updateWatchFace
,並透過手機上的 MessageClient
觸發手錶即可。
- 啟用: 將已安裝的錶面設為使用中。這個步驟有幾種可能的路徑,視權限狀態而定:
- 無須採取任何行動。市集可能已控制使用中的錶面。
- 可能不需要使用者介入。應用程式具備設定使用中錶面的必要權限,因此可以直接使用
setWatchFaceAsActive()
執行這項操作。
- 可能需要相關指引,說明如何接受權限要求,或如何使用長按手勢或透過隨附應用程式手動設定錶面。
安裝回應
為利於「啟用」階段,請確保「安裝」階段會將下列資訊從手錶傳回手機:
- 嘗試安裝的結果
isWatchFaceActive()
的結果 - 判斷應用程式是否已擁有使用中錶面。
setWatchFaceAsActive()
是否已在過去呼叫過 - Wear OS 應用程式應在本機追蹤並保存這項資訊。這個 API 呼叫只能使用一次。
啟用
安裝完成後,回應可能會指出應用程式已擁有有效錶面。但如果沒有,應用程式可能會選擇顯示「將錶面設為使用中」按鈕。
情境 1:所有設定使用中錶面的嘗試都已用盡
如果安裝的回應指出 setWatchFaceAsActive()
先前已呼叫過,按鈕應會連往手機上的教學畫面,向使用者說明如何觸控並按住錶面,手動將錶面設為所需樣式。
情境 2 - 嘗試設定使用中的錶面
手機應指示手錶檢查必要的SET_PUSHED_WATCH_FACE_AS_ACTIVE
權限:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間: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."]]