wear-widgets
できること
このスキルは、Glance WearとRemote Composeを使うWear OSのウィジェットを、作成、移行、確認する方法を導きます。ウィジェットのクラス、レイアウトの要素、状態を扱います。スマートウォッチのウィジェットを作るAndroid開発者向けです。
使う場面
- ✓Glance WearとRemote Composeを使って、Wear OSのウィジェットを作りたいとき。
- ✓Wear OSのタイルを、ウィジェットに移行する必要があるとき。
- ✓腕時計のウィジェットにボタンのアクションや、変化するローカルの状態が必要なとき。
スキルのリンク
https://github.com/android/skills/blob/main/wear/wear-widgets/SKILL.mdコピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。
使い方
いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。
貼り付け用メッセージ
Claude Code、Codex、Cursorの場合:プロジェクトのフォルダで実行するとスキルがインストールされます。
SKILL.mdをダウンロードして、エージェントのスキル用フォルダに入れてください。
AIへの頼み方の例
“次のカレンダーの予定を表示し、完了にするボタンのあるWear OSのウィジェットを作ってください。”
毎週5つの新しいスキル。1分で読めます。
仕組み
このスキルは、最新のライブラリのバージョンを特定し、SDKとComposeの要件を設定します。そのうえで、ウィジェットのサービスとUIを作ります。ウィジェットのクリックのアクションとローカルの状態も追加します。
技術的な内容(元のSKILL.md)
作者による元のテキスト(英語)をGitHubからそのまま表示しています。
Wear OS widgets use androidx.glance.wear (GlanceWearWidget and
GlanceWearWidgetService) with androidx.compose.remote (Remote Compose).
They serialize declarative UI and state documents to the watch host process.
Prerequisites and setup
Resolve library versions : Resolve the latest versions for
{GLANCE_WEAR_VERSION}(androidx.glance.wear),{COMPOSE_REMOTE_VERSION}(androidx.compose.remote), and{WEAR_COMPOSE_REMOTE_VERSION}(androidx.wear.compose.remote). Include-alpha,-beta, or-rcreleases when no stable version exists yet. Don't run./gradlew dependenciesto resolve versions:- Use an available dependency lookup tool if present.
- Otherwise, fetch the latest version from Google Maven metadata (Glance Wear metadata, Compose Remote metadata, Wear Compose Remote metadata).
SDK and Compose compiler requirements : Ask permission before modifying repo-wide Gradle files unless the user requested widget creation, tile migration, or dependency setup. Set
compileSdk = 37or higher and enablebuildFeatures { compose = true }. Keep the project's existing Android and Kotlin Gradle plugin declarations intact.dependencies { implementation("androidx.glance.wear:wear:{GLANCE_WEAR_VERSION}") implementation("androidx.glance.wear:wear-core:{GLANCE_WEAR_VERSION}") implementation("androidx.glance.wear:wear-tooling-preview:{GLANCE_WEAR_VERSION}") implementation("androidx.compose.remote:remote-creation-compose:{COMPOSE_REMOTE_VERSION}") implementation("androidx.compose.remote:remote-creation:{COMPOSE_REMOTE_VERSION}") implementation("androidx.compose.remote:remote-core:{COMPOSE_REMOTE_VERSION}") implementation("androidx.compose.remote:remote-tooling-preview:{COMPOSE_REMOTE_VERSION}") implementation("androidx.wear.compose.remote:remote-material3:{WEAR_COMPOSE_REMOTE_VERSION}") }
Codebase exploration
- Search the module for existing
TileService,Material3TileService, orGlanceWearWidgetimplementations,<service>entries inapp/src/main/AndroidManifest.xml, and@drawable/preview assets underapp/src/main/res/. - When migrating an existing tile or modifying an unfamiliar multi-module project, run
./gradlew :app:assembleDebugto verify baseline build health.
Workflow
Step 1: Configure AndroidManifest.xml and provider XML
Register the GlanceWearWidgetService subclass in
app/src/main/AndroidManifest.xml with the BIND_TILE_PROVIDER permission and
BIND_WIDGET_PROVIDER intent action. Attach <meta-data> pointing to an
@xml/ <wearwidget-provider> resource with SMALL and LARGE <container>
entries. When configuring the service, provider XML, or legacy TileService
migration, you MUST follow Widget service and manifest reference.
<service
android:name=".snippets.widget.skill.MyWidgetService"
android:exported="true"
android:permission="com.google.android.wearable.permission.BIND_TILE_PROVIDER">
<intent-filter>
<action android:name="androidx.glance.wear.action.BIND_WIDGET_PROVIDER" />
</intent-filter>
<meta-data
android:name="androidx.glance.wear.widget.provider"
android:resource="@xml/my_widget_info" />
</service>
Step 2: Implement GlanceWearWidget and GlanceWearWidgetService
Extend GlanceWearWidget and override provideWidgetData returning
WearWidgetDocument. Annotate the GlanceWearWidgetService subclass with
@AssociateWithGlanceWearWidget for static provider resolution:
// WRONG: Mobile GlanceAppWidget API (don't use on Wear OS)
class BrokenWidget : GlanceAppWidget() {
override suspend fun provideGlance(context: Context, id: GlanceId) {}
}
// CORRECT: Wear OS GlanceWearWidget + GlanceWearWidgetService
@AssociateWithGlanceWearWidget(MyWidget::class)
class MyWidgetService : GlanceWearWidgetService() {
override val widget: GlanceWearWidget = MyWidget()
}
class MyWidget : GlanceWearWidget() {
override suspend fun provideWidgetData(
context: Context,
params: WearWidgetParams,
): WearWidgetData =
WearWi
よくある質問
リポジトリ全体のGradleファイルを、勝手に変更しますか?
あなたがウィジェットの作成や依存関係の設定を頼んだ場合を除き、リポジトリ全体のGradleファイルを変更する前に許可を求めます。
ライブラリのバージョンはどう見つけますか?
利用可能な検索ツールか、公式のGoogle Mavenのメタデータを使います。依存関係のコマンドは実行しません。
アルファ版やベータ版にも対応していますか?
はい。安定版がまだない場合、アルファ版、ベータ版、リリース候補版を使うことがあります。
詳細
作者による元の説明
Create, migrate, update, and verify Wear OS widgets using Glance Wear and Remote Compose in an Android project. Use this skill when implementing GlanceWearWidget, GlanceWearWidgetService, WearWidgetDocument, Remote Compose UI primitives (RemoteColumn, RemoteRow, RemoteBox, RemoteText, RemoteImage, RemoteButton), local state with rememberMutableRemoteInt and valueChange, click actions with pendingIntentAction, widget provider XML containers (SMALL and LARGE), rectangular widget picker PNG previews, or migrating legacy ProtoLayout TileService tiles to Wear OS widgets. Don't use for mobile home s
repo: android/skills
人気
- GitHubのスター
- 10k
- ランキング
- #11940
- ライセンス
- Apache-2.0
- 更新日
- 2026/10/29
コメント
- …
このリポジトリの他のスキル
agp-9-upgrade
10kエージェントが、AndroidアプリをAndroid Gradle Plugin 9にアップグレードし、その破壊的変更に対応できるよう支援します。マルチプラットフォームのプロジェクトは対象外です。
camerax
10kエージェントが、CameraXを使ってAndroidのカメラ機能を作れるよう支援します。動画の録画、ハードウェアの制御、ML Kit、Media3のエフェクトを含みます。
android-for-cars-parked-apps
10kエージェントが、Androidの動画、ゲーム、ブラウザのアプリを、Android AutoとAndroid Automotiveで駐車中のアプリとして動かせるように適合させるよう支援します。
appfunctions
10kエージェントが、Androidアプリの主要な作業の流れを見つけ、AIエージェントや音声コマンドが実行できるAppFunctionsとして公開できるよう支援します。
似ているスキル
android-clean-architecture
280kエージェントがAndroidプロジェクトを効率よく整理できるようにします。コードを構造化して、保守や新機能の開発をしやすくします。
compose-multiplatform-patterns
280kエージェントがKMPプロジェクトでCompose MultiplatformとJetpack Composeのパターンを使えるようにします。状態管理、ナビゲーション、テーマ設定、パフォーマンスを扱います。
dart-flutter-patterns
280kエージェントがDartとFlutterのアプリ向けのコードを書けるようにします。最新のパターンを使い、堅牢で管理しやすいアプリを作ります。