Pular para o conteúdo
Skillpedia
Apps de celular10 mil · #11940

wear-widgets

O que ela faz

Esta skill orienta a criação, a migração e a verificação de widgets Wear OS que usam Glance Wear e Remote Compose. Ela cobre as classes do widget, os elementos de layout e o estado. Ela é para desenvolvedores Android que criam widgets para smartwatches.

Quando usar

  • ✓Quando você quer criar um widget Wear OS com Glance Wear e Remote Compose.
  • ✓Quando você precisa migrar um tile do Wear OS para um widget.
  • ✓Quando seu widget de relógio precisa de ações de botão ou de um estado local que muda.

Link da skill

https://github.com/android/skills/blob/main/wear/wear-widgets/SKILL.md

Copie e cole na sua IA (Claude, ChatGPT ou Cursor) pedindo para seguir as instruções.

Como usar

O jeito mais fácil: copie a mensagem e cole na sua IA. Ela lê a skill e segue as instruções.

Mensagem pronta para colar

Use esta skill para me ajudar: https://github.com/android/skills/blob/main/wear/wear-widgets/SKILL.md Leia o arquivo SKILL.md desse link e siga as instruções dele na minha tarefa.
Quer que a sua IA encontre skills como esta sozinha?Instale o MCP grátis do Skillpedia: uma linha, e ela pesquisa entre 15.000+ skills antes de cada tarefa.Instalar em 1 minuto →

Exemplo do que pedir para a IA

“Crie um widget Wear OS que mostre meu próximo evento da agenda e um botão para marcá-lo como concluído.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A skill identifica as versões mais recentes das bibliotecas, define os requisitos de SDK e Compose e depois cria o serviço e a interface do widget. Ela também adiciona ações de clique e estado local para o widget.

Conteúdo técnico (SKILL.md original)

Texto original do autor, em inglês, direto do 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

  1. 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 -rc releases when no stable version exists yet. Don't run ./gradlew dependencies to resolve versions:

  2. 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 = 37 or higher and enable buildFeatures { 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

  1. Search the module for existing TileService, Material3TileService, or GlanceWearWidget implementations, <service> entries in app/src/main/AndroidManifest.xml, and @drawable/ preview assets under app/src/main/res/.
  2. When migrating an existing tile or modifying an unfamiliar multi-module project, run ./gradlew :app:assembleDebug to 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
Perguntas frequentes

Ela vai mudar meus arquivos Gradle sozinha?

Ela pede permissão antes de alterar arquivos Gradle de todo o repositório, a menos que você tenha pedido a criação do widget ou a configuração de dependências.

Como ela encontra as versões das bibliotecas?

Ela usa uma ferramenta de consulta disponível ou os metadados oficiais do Google Maven, em vez de executar comandos de dependências.

Ela oferece suporte a versões alfa ou beta?

Sim. Se ainda não existir uma versão estável, a skill pode usar uma versão alfa, beta ou release candidate.

Detalhes

Descrição original do autor

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

Popularidade

Estrelas no GitHub
10 mil
Posição no ranking
#11940
Licença
Apache-2.0
Atualizada em
29/10/2026

Essa skill é útil?

0

Entre para votar.

Comentários

  • …

Mais skills deste repositório

Skills parecidas