glance-appwidget-updates-and-memory
Qué hace
Esta skill guía la actualización de los widgets de la pantalla de inicio de Android creados con Jetpack Glance o RemoteViews. Cubre la actualización de contenido desactualizado o congelado en el widget y mantener las imágenes dentro de los límites de memoria de Android 17. Es para desarrolladores de Android que mantienen widgets de app.
Cuándo usarla
- ✓Cuando un widget de Glance en la pantalla de inicio muestra contenido antiguo o congelado tras una sincronización en segundo plano.
- ✓Cuando configuras un widget de Android 17 y necesitas que sus imágenes no superen el límite de memoria.
- ✓Cuando mantienes un AppWidgetProvider clásico y quieres actualizarlo correctamente.
Link de la skill
https://github.com/android/skills/blob/main/system/glance-appwidget-updates-and-memory/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Mi widget de Glance deja de actualizarse tras la sincronización en segundo plano. Corrige la actualización y mantén las imágenes pequeñas.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
La skill comprueba los ajustes de compilación y del manifiesto, y luego reduce las imágenes al tamaño del widget. También actualiza el estado del widget para que la pantalla de inicio muestre el contenido más reciente.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de GitHub.
This skill provides guidance for managing state updates and keeping Android
AppWidgets that use Jetpack Glance (androidx.glance:glance-appwidget) or
RemoteViews within the Android 17 widget bitmap memory limits. For widget UI
layout templates, suggest the glance-canonical-layouts skill.
- When configuring a Glance widget, see Create an app widget with Glance.
- When targeting Android 17 (
targetSdk = 37), see Android 17 widget memory limits. - When maintaining a classic
AppWidgetProvider, see Create an app widget.
Prerequisites
- Kotlin Android project (
minSdk >= 26) withcompileSdk = 37(targetSdk = 37when targeting Android 17) inbuild.gradle.kts. - Jetpack Glance (
1.2.0, minimum1.1.1+) and the Compose compiler Gradle plugin enabled on the module.
Critical mandates
- Preserve existing package name and toolchain versions : Inspect
build.gradle.kts,gradle/libs.versions.toml, and Kotlin files first. Keep existingnamespace,applicationId,package,targetSdk(unless migrating to Android 17), Android Gradle Plugin (AGP), and Kotlin versions. - Downsample images to widget dimensions and estimate the memory cap : Android
system_servercomputes theRemoteViewsbitmap memory cap (6 * width * heightbytes, or1.5 * 4 * width * height) once at boot from the real size of the default display and does not expose this cap in a public API. Because unfolding a foldable or switching display resolution toQHD+after boot can make active window metrics report a larger value than the boot-time cap, always downsample each image first to the widget's target dimensions (maxWidthDp x maxHeightDpinRGB_565orALPHA_8), and enforce the per-image byte ceiling (calculateWidgetMemoryCapBytes(context) / distinctImageCount) estimated as6 * width * heightfromWindowManager.currentWindowMetrics.boundson API 30+ (falling back toresources.displayMetricson API 26-29 or ifWindowManageris unavailable). - Decode shared bitmaps once outside provideContent : Both
SizeMode.Exact(used byglance-canonical-layoutsto compose the current span's portrait and landscape orientations) andSizeMode.Responsive(used to pre-bundle a set ofDpSizebreakpoints) invokeprovideContentmultiple times per update. Decode shared bitmaps once inprovideGlancebeforeprovideContentand pass them toImageProvider(bitmap)soRemoteViewsdeduplicates the sharedBitmapacross all sizes in either mode. If a widget scales distinct bitmaps perLocalSize.current, dividecalculateWidgetMemoryCapBytes(context)by the number of distinct bitmaps. - Downsample content URIs and grant launcher read permissions : On Android 17 (
targetSdk >= 37), bitmap-backedIcons count toward the cap alongsideBitmaps.content://URIs passed toImageProvider(uri)orRemoteViews.setImageViewUridon't count toward the inter-process communication (IPC) cap, but the launcher decodes them at full resolution. Downsample the file intocontext.cacheDir, expose it withFileProvider.getUriForFile, and grantIntent.FLAG_GRANT_READ_URI_PERMISSIONtoIntent.CATEGORY_HOMEpackages. - Trigger explicit widget updates after state mutations :
updateAppWidgetStatewrites preferences to DataStore without updating the widget UI. After you mutate state, callGlanceAppWidget.update(context, glanceId)orGlanceAppWidget.updateAll(context). - Use full updateAppWidget calls when you replace images : In
AppWidgetProviderclasses, when you replace bitmaps orIcons, callAppWidgetManager.updateAppWidgetinstead ofpartiallyUpdateAppWidget.
Reference implementation files
Read the companion reference files in references/ when implementing each step,
and update the sample package declaration and class names to match your app:
- Bitmap Cap & FileProvider Helper : WidgetBitmapUtils.kt
- Responsive Widget, Receiver & Error Fallback : SampleGlanceWidget.kt
- LazyColumn Collection Widget & Revision Cache : FeedCollectionGlanceWidget.kt
- DataStore State Push, CoroutineWorker & ActionCallback : [WidgetStateAndActions.kt](references/WidgetStateAndAct
Preguntas frecuentes
¿Qué versión de Android tiene como objetivo?
Cubre los límites de memoria de los widgets de Android 17 (API 37) y los ajustes necesarios para apuntar a esa versión.
¿Necesito Glance?
La skill está pensada para widgets de Jetpack Glance, y también cubre los widgets clásicos de RemoteViews.
¿Diseña la maqueta del widget?
Las plantillas de diseño las gestiona una skill aparte de diseños canónicos.
Detalles
Descripción original del autor
Manages Android AppWidget state updates, background syncs, and RemoteViews bitmap memory limits with Jetpack Glance (androidx.glance:glance-appwidget) and AppWidgetProvider receivers on Android 17 (API 37). Use this skill when configuring Android 17 (API level 37) compileSdk/targetSdk and AndroidManifest.xml widget receivers, refreshing frozen or stale Glance widget UI after CoroutineWorker DataStore preference updates (updateAppWidgetState), downsampling images within the WindowMetrics memory limit for SizeMode.Responsive, SizeMode.Exact, or LazyColumn, sharing content:// URIs with FileProvid
repo: android/skills
Popularidad
- Estrellas en GitHub
- 10 mil
- Posición en el ranking
- #11935
- Licencia
- Apache-2.0
- Actualizada
- 29/10/2026
Comentarios
- …
Más skills de este repositorio
agp-9-upgrade
10 milAyuda a tu agente a actualizar una app de Android a Android Gradle Plugin 9 y a resolver sus cambios incompatibles. No sirve para proyectos multiplataforma.
camerax
10 milAyuda a tu agente a crear funciones de cámara en Android con CameraX, incluida la grabación de vídeo, los controles del hardware y los efectos de ML Kit y Media3.
android-for-cars-parked-apps
10 milAyuda a tu agente a adaptar una app de Android de vídeo, juegos o navegador para que funcione como app aparcada en Android Auto y Android Automotive.
appfunctions
10 milAyuda a tu agente a encontrar los flujos de trabajo clave de una app de Android y a exponerlos como AppFunctions que los agentes de IA y los comandos de voz pueden ejecutar.
Skills parecidas
android-clean-architecture
280 milHace que tu agente organice proyectos de Android de forma eficiente. Estructura el código para facilitar el mantenimiento y el desarrollo de nuevas funciones.
compose-multiplatform-patterns
280 milAyuda a tu agente a usar patrones de Compose Multiplatform y Jetpack Compose en proyectos KMP, incluyendo estado, navegación, temas y rendimiento.
dart-flutter-patterns
280 milHace que tu agente escriba código para apps de Dart y Flutter. Usa patrones modernos para crear apps robustas y fáciles de mantener.