Định cấu hình ứng dụng điện thoại cho tính năng đẩy mặt đồng hồ
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Đối với trang web thương mại chính thức, ứng dụng điện thoại là cách thức chủ yếu mà người dùng tương tác với ứng dụng.
Đặt mặt đồng hồ
Khi người dùng chọn một mặt đồng hồ trong ứng dụng điện thoại, sẽ có 2 phần trong quy trình tiếp theo để đặt mặt đồng hồ:
Cài đặt: Cài đặt mặt đồng hồ bằng Watch Face Push, được khởi chạy thông qua MessageClient. Bước này khá đơn giản, bạn có thể dùng addWatchFace hoặc updateWatchFace, được kích hoạt bằng MessageClient từ điện thoại đến đồng hồ.
Có thể bạn không cần làm gì cả. Thị trường có thể đã kiểm soát mặt đồng hồ đang hoạt động.
Có thể không cần người dùng can thiệp. Ứng dụng có các quyền cần thiết để đặt mặt đồng hồ đang hoạt động và có thể thực hiện việc này trực tiếp bằng cách sử dụng setWatchFaceAsActive().
Có thể bạn cần được hướng dẫn về cách chấp nhận yêu cầu cấp quyền hoặc cách đặt mặt đồng hồ theo cách thủ công bằng cử chỉ nhấn và giữ hoặc thông qua ứng dụng đồng hành.
Phản hồi về việc cài đặt
Để tạo điều kiện thuận lợi cho giai đoạn Kích hoạt, giai đoạn Cài đặt phải trả về thông tin sau từ đồng hồ sang điện thoại:
Kết quả của lần thử cài đặt
Kết quả của isWatchFaceActive() – để xác định xem ứng dụng đã có mặt đồng hồ đang hoạt động hay chưa.
Liệu setWatchFaceAsActive() đã được gọi trong quá khứ hay chưa – ứng dụng Wear OS nên theo dõi và duy trì thông tin này cục bộ. Bạn chỉ có thể sử dụng lệnh gọi API này một lần.
Cách triển khai
Sau khi cài đặt, phản hồi có thể cho biết rằng ứng dụng đã có mặt đồng hồ đang hoạt động. Tuy nhiên, nếu không, ứng dụng có thể chọn hiện một nút để đặt mặt đồng hồ làm mặt đồng hồ chính.
Trường hợp 1: Đã hết tất cả các lần thử đặt mặt đồng hồ đang hoạt động
Nếu phản hồi từ quá trình cài đặt cho biết setWatchFaceAsActive() đã được gọi trước đây, thì nút này sẽ dẫn đến một màn hình hướng dẫn trên điện thoại, cho người dùng biết cách chạm và giữ trên mặt đồng hồ để đặt mặt đồng hồ theo cách thủ công thành mặt đồng hồ mà họ muốn.
Trường hợp 2 – Thử đặt mặt đồng hồ đang hoạt động
Điện thoại sẽ hướng dẫn đồng hồ kiểm tra quyền SET_PUSHED_WATCH_FACE_AS_ACTIVE cần thiết:
Nếu người dùng đã cấp quyền này, hãy chuyển sang gọi setWatchFaceAsActive().
Nếu người dùng trước đây đã từ chối cấp quyền, thì đồng hồ phải thông báo lại cho điện thoại. Tại đây, một màn hình hướng dẫn có thể xuất hiện để giải thích lý do cần có quyền và cách cấp quyền theo cách thủ công.
Nếu trước đây chưa từng yêu cầu quyền, thì đồng hồ phải hướng dẫn điện thoại cho người dùng xem một thông báo hướng dẫn cách chấp nhận quyền trên đồng hồ, đồng thời đồng hồ phải tiếp tục yêu cầu quyền.
Nếu người dùng cấp quyền, thì đồng hồ sẽ gọi setWatchFaceAsActive().
Nếu không, đồng hồ sẽ hướng dẫn điện thoại hiển thị một màn hình hướng dẫn giải thích sự cần thiết của quyền này và cách cấp quyền theo cách thủ công.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-08-29 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],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."]]