Imported from MihaiCristianCondrea/App-Toolkit-for-Android (
.agents/skills/glance-widget/SKILL.md). Install upstream withnpx skills add MihaiCristianCondrea/App-Toolkit-for-Android --skill glance-widget. Copyright stays with the author.
Android Glance Widget
Follow Google's official Jetpack Glance guidance.
The references/ directory contains local copies of the official Google
documentation used by this skill.
Treat those files as read-only reference material:
- Do not edit, rewrite, summarize into, reformat, or otherwise modify them.
- Do not fetch the same documentation again when the local reference already exists.
- Read only the reference files relevant to the current task.
- Prefer the local references over general architectural assumptions or memory.
- If the local documentation does not cover a question, consult the official Android documentation only when additional verification is actually needed.
Core rules
- Use Glance APIs for widget UI. Do not assume regular Jetpack Compose UI elements are directly interoperable with Glance.
- Keep
GlanceAppWidgetstateless and passive; keep durable application state in the application's source of truth and use Glance state only for widget-specific state when appropriate. - Update widgets intentionally when data/state changes. Use persistent scheduling only when the update must outlive the current process/lifecycle.
- Use Glance action APIs for widget interaction.
- Respect AppWidget/RemoteViews limitations even when the API looks Compose-like.
- Prefer the smallest implementation supported by the official guidance.
Reference routing
Read:
references/create-app-widget.mdfor initial widget setup, receiver, manifest/provider metadata, sizing modes, and basic creation.references/enhance.mdfor widget picker name/description and optional experience improvements.references/configuration.mdfor configuration activities and reconfiguration.references/generated-previews.mdfor Android 15+ generated previews and preview fallbacks.references/pin-in-app.mdfor requesting widget pinning from inside the app.references/error-handling.mdfor composition errors, fallback layouts, and custom error handling.references/testing.mdfor Glance unit testing, matchers, context, and size.references/user-interaction.mdfor clicks, activities, services, broadcasts, callbacks, and action parameters.references/metrics.mdfor widget interaction/event metrics.references/glance-app-widget.mdfor widget state, updates, update timing,update,updateAll,updateIf, and background update work.references/build-ui.mdfor layouts, components, responsive sizing, and Glance UI construction.references/theme.mdforGlanceTheme, colors, Material interop, and widget styling.references/interoperability.mdforAndroidRemoteViewsand XML/RemoteViewsinteroperability.references/additional-resources.mdfor official samples, demos, design resources, and API references.
Workflow
- Inspect the existing widget, receiver, provider XML, manifest registration, state/update path, and relevant app data source.
- Identify the Glance topic involved.
- Read the matching official reference before changing behavior.
- Follow existing project conventions unless they conflict with the official Glance contract.
- Make the smallest complete change.
- Add or update tests when widget behavior being changed is testable with the Glance testing APIs.
- Do not introduce regular Compose UI APIs into Glance code merely because
both use
@Composable.
Review
Check for:
- regular Compose UI APIs mixed into Glance without supported interoperability;
- incorrect receiver/provider/manifest setup;
- in-memory widget state relied on as durable state;
- missing or excessive widget updates;
- unsupported interaction patterns;
- sizing/layout assumptions that ignore widget host sizes;
- configuration, preview, pinning, or error behavior that contradicts the corresponding official guide;
- missing relevant Glance tests.
When uncertain, read the relevant official reference rather than guessing.
Official source index
create-app-widget.md→ https://developer.android.com/develop/ui/compose/glance/create-app-widget.md.txtenhance.md→ https://developer.android.com/develop/ui/compose/glance/enhance.md.txtconfiguration.md→ https://developer.android.com/develop/ui/compose/glance/configuration.md.txtgenerated-previews.md→ https://developer.android.com/develop/ui/compose/glance/generated-previews.md.txtpin-in-app.md→ https://developer.android.com/develop/ui/compose/glance/pin-in-app.md.txterror-handling.md→ https://developer.android.com/develop/ui/compose/glance/error-handling.md.txttesting.md→ https://developer.android.com/develop/ui/compose/glance/testing.md.txtuser-interaction.md→ https://developer.android.com/develop/ui/compose/glance/user-interaction.md.txtmetrics.md→ https://developer.android.com/develop/ui/compose/glance/metrics.md.txtglance-app-widget.md→ https://developer.android.com/develop/ui/compose/glance/glance-app-widget.md.txtbuild-ui.md→ https://developer.android.com/develop/ui/compose/glance/build-ui.md.txttheme.md→ https://developer.android.com/develop/ui/compose/glance/theme.md.txtinteroperability.md→ https://developer.android.com/develop/ui/compose/glance/interoperability.md.txtadditional-resources.md→ https://developer.android.com/develop/ui/compose/glance/additional-resources.md.txt