The Watch Face Format is required for watch faces to be installed on devices with Wear OS 5 or later pre-installed and for all new watch faces published on Google Play.
Starting in January 2026, the Watch Face Format will be required for watch faces to be installed on all Wear OS devices.
Learn more about the user-facing changes in this Help Center article.
打造錶面服務
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
錶面是 Wear OS 應用程式內隨附的服務。當使用者選取某個可用錶面後,系統便會顯示該錶面並叫用服務回呼方法。
如果使用者安裝了含有錶面的 Wear 應用程式,便可透過錶面選取器在手錶上使用這些錶面。另外,使用者也可以在配對的手機上,透過隨附應用程式選取錶面。
本頁面將說明如何設定 Wear OS 專案來納入錶面,以及如何實作錶面服務。
建立錶面專案
注意:建議您使用 Android Studio 開發 Wear OS 應用程式,因為這項工具可以用來設定專案、加入程式庫,而且提供便利的包裝方式
如要在 Android Studio 中為錶面建立專案,請按照下列步驟操作:
- 依序點選「File」>「New」>「New Project」。
- 在「Select a project template」視窗中選取「Wear」分頁標籤,然後從選項清單中選取「Watch Face」,再按一下「Next」。
- 在「Configure your project」視窗中接受預設值,然後按一下「Finish」。
Android Studio 會針對錶面服務建立含有 app
模組的專案。
依附元件
Android Studio 會自動把必要的依附元件加入 build.gradle
檔案。依附元件包含 AndroidX 錶面程式庫;如要進一步瞭解這個程式庫,請參閱 GitHub 上的程式碼範例。
穿戴式裝置支援資料庫 API 參考資料
參考資料說明文件提供可用來實作錶面的類別詳細資訊。請參閱 API 參考資料說明文件,瞭解穿戴式裝置支援資料庫。
宣告權限
錶面必須使用 WAKE_LOCK
權限。請前往 Wear OS 應用程式和手機應用程式資訊清單檔案,在 manifest
元素下方新增以下權限:
<manifest ...>
<uses-permission
android:name="android.permission.WAKE_LOCK" />
<!-- Required for complications to receive complication data and open the provider chooser. -->
<uses-permission
android:name="com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA"/>
...
</manifest>
支援直接啟動
您必須按照直接啟動相關指南,在使用者解鎖前提供錶面:
- 在資訊清單中,將服務的
android:directBootAware
屬性設為 true
。
- 錶面應將資訊儲存在裝置的加密儲存空間。
實作服務和回呼方法
Wear OS 內的錶面會實作為 WatchFaceService
。實作 WatchFaceService
需要建立三個物件:UserStyleSchema
、ComplicationSlotsManager
和 WatchFace
。
這三個物件的指定方式是覆寫 WatchFaceService
中的三個抽象方法,如以下範例所示:
Kotlin
class CustomWatchFaceService : WatchFaceService() {
/**
* The specification of settings the watch face supports.
* This is similar to a database schema.
*/
override fun createUserStyleSchema(): UserStyleSchema = // ...
/**
* The complication slot configuration for the watchface.
*/
override fun createComplicationSlotsManager(
currentUserStyleRepository: CurrentUserStyleRepository
): ComplicationSlotsManager = // ...
/**
* The watch face itself, which includes the renderer for drawing.
*/
override suspend fun createWatchFace(
surfaceHolder: SurfaceHolder,
watchState: WatchState,
complicationSlotsManager: ComplicationSlotsManager,
currentUserStyleRepository: CurrentUserStyleRepository
): WatchFace = // ...
}
註冊錶面服務
實作錶面服務後,請在穿戴式應用程式的資訊清單檔案中註冊實作項目。使用者安裝此應用程式後,系統會使用服務相關資訊,在 Wear OS 隨附應用程式和穿戴式裝置的錶面挑選工具中提供此錶面。
以下範例說明如何在 <application>
元素下方註冊錶面實作內容:
<service
android:name=".AnalogWatchFaceService"
android:label="@string/analog_name"
android:permission="android.permission.BIND_WALLPAPER" >
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/watch_face" />
<meta-data
android:name="com.google.android.wearable.watchface.preview_circular"
android:resource="@drawable/preview_analog_circular" />
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
<category
android:name=
"com.google.android.wearable.watchface.category.WATCH_FACE" />
</intent-filter>
</service>
當系統向使用者展示裝置內安裝的所有錶面時,Wear OS by Google 隨附應用程式和穿戴式裝置的錶面挑選工具都會使用 com.google.android.wearable.watchface.preview_circular
中繼資料項目定義的預覽圖片。如果要取得這個可繪項目,請在 Wear OS 裝置或模擬器執行個體中執行錶面,然後擷取螢幕截圖。在配備 HDPI 螢幕的 Wear 裝置上,預覽圖片大小通常為 320 x 320 像素。
android.service.wallpaper
中繼資料項目會指定 watch_face.xml
資源檔案,其中含有 wallpaper
元素,如以下範例所示:
<?xml version="1.0" encoding="UTF-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android" />
穿戴式應用程式內可以附有多種錶面。對於所有錶面實作項目,您都必須在穿戴式應用程式的資訊清單檔案中新增一個服務項目。
請參閱下列相關資源:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[[["容易理解","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-07-26 (世界標準時間)。"],[],[],null,["# Build a watch face service\n\nA watch face is a [service](/guide/components/services)\npackaged in a [Wear OS app](/training/wearables/apps).\nWhen a user selects an available watch face, the watch face displays and the\nservice callback methods are invoked.\n\nWhen a user installs a Wear app that has watch faces, the watch\nfaces are available on the watch using the watch face selector.\nAlternatively, the user can select a watch face from a companion app on the paired phone.\n\nThis page describes how to configure a Wear OS project to include watch faces and how\nto implement a watch face service.\n\nCreate a watch face project\n---------------------------\n\n**Note:** We recommend that you use [Android Studio](/studio) for Wear OS development, as\nit provides project setup, library inclusion, and packaging conveniences.\n\nComplete the following steps to\n[create a project](/studio/projects/create-project#StartAProject)\nin Android Studio for your watch face:\n\n1. Click **File** \\\u003e **New** \\\u003e **New project**.\n2. In the **Select a project template** window, select the **Wear** tab, then select **Watch Face** from the list of options and click **Next**.\n3. In the **Configure your project** window, accept the default values and click **Finish**.\n\nAndroid Studio creates a project with an `app` module for your watch face service.\n\n### Dependencies\n\nAndroid Studio automatically adds the required dependencies in your `build.gradle`\nfiles. Included in the dependencies is the\n[AndroidX\nwatch face library](/reference/kotlin/androidx/wear/watchface/package-summary); see the\n[code sample](https://github.com/android/wear-os-samples/tree/main/WatchFaceKotlin) on GitHub for details about this library.\n\n### Wearable support library API reference\n\nThe reference documentation provides detailed information about the classes you use to\nimplement watch faces. Browse the\n[API reference\ndocumentation](/reference/android/support/wearable/watchface/package-summary) for the Wearable support library.\n\n### Declare permissions\n\nA watch face requires the `WAKE_LOCK` permission.\nAdd the following permission to the manifest files of both the Wear OS app\nand the mobile phone app under the `manifest` element: \n\n```xml\n\u003cmanifest ...\u003e\n \u003cuses-permission\n android:name=\"android.permission.WAKE_LOCK\" /\u003e\n\n \u003c!-- Required for complications to receive complication data and open the provider chooser. --\u003e\n \u003cuses-permission\n android:name=\"com.google.android.wearable.permission.RECEIVE_COMPLICATION_DATA\"/\u003e\n ...\n\u003c/manifest\u003e\n```\n\n### Support direct-boot\n\nYou must make your watchface available before user-unlock by following\n[Direct Boot](https://developer.android.com/training/articles/direct-boot) guidance:\n\n1. Set `android:directBootAware` attribute to `true` for your service in your manifest.\n2. Your watch face should store information in [device encrypted storage](https://developer.android.com/training/articles/direct-boot#access).\n\n\u003cbr /\u003e\n\nImplement the service and callback methods\n------------------------------------------\n\nWatch faces in Wear OS are implemented as a\n[`WatchFaceService`](/reference/kotlin/androidx/wear/watchface/WatchFaceService).\nImplementing a `WatchFaceService` requires creating three objects: a\n`UserStyleSchema`, a `ComplicationSlotsManager`, and a\n`WatchFace`.\n\nThese three objects are specified by overriding three abstract methods from\n`WatchFaceService`, shown in the following example: \n\n### Kotlin\n\n```kotlin\nclass CustomWatchFaceService : WatchFaceService() {\n\n /**\n * The specification of settings the watch face supports.\n * This is similar to a database schema.\n */\n override fun createUserStyleSchema(): UserStyleSchema = // ...\n\n /**\n * The complication slot configuration for the watchface.\n */\n override fun createComplicationSlotsManager(\n currentUserStyleRepository: CurrentUserStyleRepository\n ): ComplicationSlotsManager = // ...\n\n /**\n * The watch face itself, which includes the renderer for drawing.\n */\n override suspend fun createWatchFace(\n surfaceHolder: SurfaceHolder,\n watchState: WatchState,\n complicationSlotsManager: ComplicationSlotsManager,\n currentUserStyleRepository: CurrentUserStyleRepository\n ): WatchFace = // ...\n\n}\n```\n\nRegister the watch face service\n-------------------------------\n\nAfter you implement the watch face service, register the implementation in the manifest\nfile of the wearable app. When users install this app, the system uses the information about\nthe service to make the watch face available in the [Wear OS companion app](https://play.google.com/store/apps/details?id=com.google.android.wearable.app&hl=en) and in the watch face picker on the wearable device.\n\nThe following sample shows how to register a watch face implementation\nunder the [`\u003capplication\u003e`](/guide/topics/manifest/application-element) element: \n\n```xml\n\u003cservice\n android:name=\".AnalogWatchFaceService\"\n android:label=\"@string/analog_name\"\n android:permission=\"android.permission.BIND_WALLPAPER\" \u003e\n \u003cmeta-data\n android:name=\"android.service.wallpaper\"\n android:resource=\"@xml/watch_face\" /\u003e\n \u003cmeta-data\n android:name=\"com.google.android.wearable.watchface.preview_circular\"\n android:resource=\"@drawable/preview_analog_circular\" /\u003e\n \u003cintent-filter\u003e\n \u003caction android:name=\"android.service.wallpaper.WallpaperService\" /\u003e\n \u003ccategory\n android:name=\n \"com.google.android.wearable.watchface.category.WATCH_FACE\" /\u003e\n \u003c/intent-filter\u003e\n\u003c/service\u003e\n```\n\nThe Wear OS by Google companion app and the watch face picker on the wearable device use the preview\nimage defined by the `com.google.android.wearable.watchface.preview_circular` metadata entry when\npresenting users with all the watch faces installed on the device. To obtain this drawable,\nrun the watch face on your Wear OS device or in an emulator instance and\n[take a screenshot](/studio/debug/am-screenshot). On Wear\ndevices with hdpi screens, the preview image is typically 320x320 pixels in size.\n\nThe `android.service.wallpaper` metadata entry specifies the\n`watch_face.xml` resource file, which contains a `wallpaper`\nelement, as shown in the following sample: \n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cwallpaper xmlns:android=\"http://schemas.android.com/apk/res/android\" /\u003e\n```\n\nYour wearable app can contain more than one watch face. You must add a service entry to the\nmanifest file of the wearable app for each of your watch face implementations.\n\nRelated resources\n-----------------\n\n\nRefer to the following related resources:\n\n- [WatchFaceKotlin sample](https://github.com/android/wear-os-samples/tree/deprecated/WatchFaceKotlin)"]]