একটি ঘড়ির মুখ হল একটি Wear OS অ্যাপে প্যাকেজ করা একটি পরিষেবা ৷ যখন একজন ব্যবহারকারী একটি উপলব্ধ ঘড়ির মুখ নির্বাচন করেন, তখন ঘড়ির মুখটি প্রদর্শিত হয় এবং পরিষেবা কলব্যাক পদ্ধতিগুলি আহ্বান করা হয়।
যখন একজন ব্যবহারকারী ঘড়ির মুখ আছে এমন একটি Wear অ্যাপ ইনস্টল করেন, তখন ঘড়ির মুখ নির্বাচনকারী ব্যবহার করে ঘড়িতে ঘড়ির মুখগুলি পাওয়া যায়। বিকল্পভাবে, ব্যবহারকারী পেয়ার করা ফোনে একটি সহচর অ্যাপ থেকে একটি ঘড়ির মুখ নির্বাচন করতে পারেন।
এই পৃষ্ঠাটি বর্ণনা করে যে কীভাবে ঘড়ির মুখগুলি অন্তর্ভুক্ত করার জন্য একটি Wear OS প্রকল্প কনফিগার করতে হয় এবং কীভাবে একটি ঘড়ির মুখ পরিষেবা বাস্তবায়ন করা যায়৷
একটি ঘড়ির মুখ প্রকল্প তৈরি করুন
দ্রষ্টব্য: আমরা আপনাকে Wear OS ডেভেলপমেন্টের জন্য Android স্টুডিও ব্যবহার করার পরামর্শ দিই, কারণ এটি প্রকল্প সেটআপ, লাইব্রেরি অন্তর্ভুক্তি এবং প্যাকেজিং সুবিধা প্রদান করে।
আপনার ঘড়ির মুখের জন্য Android স্টুডিওতে একটি প্রকল্প তৈরি করতে নিম্নলিখিত পদক্ষেপগুলি সম্পূর্ণ করুন:
- ফাইল > নতুন > নতুন প্রকল্পে ক্লিক করুন।
- একটি প্রজেক্ট টেমপ্লেট নির্বাচন করুন উইন্ডোতে, পরিধান ট্যাবটি নির্বাচন করুন, তারপরে বিকল্পগুলির তালিকা থেকে ওয়াচ ফেস নির্বাচন করুন এবং পরবর্তীতে ক্লিক করুন।
- আপনার প্রজেক্ট কনফিগার করুন উইন্ডোতে, ডিফল্ট মানগুলি গ্রহণ করুন এবং শেষ ক্লিক করুন।
অ্যান্ড্রয়েড স্টুডিও আপনার ঘড়ির মুখ পরিষেবার জন্য একটি app
মডিউল সহ একটি প্রকল্প তৈরি করে৷
নির্ভরতা
অ্যান্ড্রয়েড স্টুডিও স্বয়ংক্রিয়ভাবে আপনার build.gradle
ফাইলগুলিতে প্রয়োজনীয় নির্ভরতা যোগ করে। নির্ভরতা অন্তর্ভুক্ত AndroidX ঘড়ি মুখ লাইব্রেরি ; এই লাইব্রেরি সম্পর্কে বিস্তারিত জানার জন্য GitHub-এ কোড নমুনা দেখুন।
পরিধানযোগ্য সমর্থন লাইব্রেরি API রেফারেন্স
রেফারেন্স ডকুমেন্টেশন আপনি ঘড়ির মুখগুলি প্রয়োগ করার জন্য যে ক্লাসগুলি ব্যবহার করেন সে সম্পর্কে বিস্তারিত তথ্য প্রদান করে। পরিধানযোগ্য সমর্থন লাইব্রেরির জন্য API রেফারেন্স ডকুমেন্টেশন ব্রাউজ করুন।
অনুমতি ঘোষণা করুন
একটি ঘড়ির মুখের জন্য WAKE_LOCK
অনুমতি প্রয়োজন৷ manifest
উপাদানের অধীনে Wear OS অ্যাপ এবং মোবাইল ফোন অ্যাপ উভয়ের ম্যানিফেস্ট ফাইলগুলিতে নিম্নলিখিত অনুমতি যোগ করুন:
<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
থেকে তিনটি বিমূর্ত পদ্ধতি ওভাররাইড করে নির্দিষ্ট করা হয়েছে, যা নিম্নলিখিত উদাহরণে দেখানো হয়েছে:
কোটলিন
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 ডিভাইসে বা এমুলেটর ইনস্ট্যান্সে ঘড়ির মুখটি চালান এবং একটি স্ক্রিনশট নিন । এইচডিপিআই স্ক্রীন সহ Wear ডিভাইসগুলিতে, পূর্বরূপ চিত্রটি সাধারণত 320x320 পিক্সেল আকারের হয়।
android.service.wallpaper
মেটাডেটা এন্ট্রি watch_face.xml
রিসোর্স ফাইলটি নির্দিষ্ট করে, যেটিতে একটি wallpaper
উপাদান রয়েছে, যেমনটি নিম্নলিখিত নমুনায় দেখানো হয়েছে:
<?xml version="1.0" encoding="UTF-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android" />
আপনার পরিধানযোগ্য অ্যাপে একাধিক ঘড়ির মুখ থাকতে পারে। আপনার প্রতিটি ঘড়ির মুখ বাস্তবায়নের জন্য পরিধানযোগ্য অ্যাপের ম্যানিফেস্ট ফাইলে আপনাকে অবশ্যই একটি পরিষেবা এন্ট্রি যোগ করতে হবে।
নিম্নলিখিত সম্পর্কিত সংস্থান পড়ুন:
এই পৃষ্ঠার কন্টেন্ট ও কোডের নমুনাগুলি Content License-এ বর্ণিত লাইসেন্সের অধীনস্থ। Java এবং OpenJDK হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-29 UTC-তে শেষবার আপডেট করা হয়েছে।
[[["সহজে বোঝা যায়","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-29 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],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)"]]