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

glance-appwidget-updates-and-memory

O que ela faz

Esta skill orienta a atualização de widgets da tela inicial do Android feitos com Jetpack Glance ou RemoteViews. Cobre a atualização de conteúdo desatualizado ou travado e a manutenção das imagens dentro dos limites de memória do Android 17. É para desenvolvedores Android que mantêm widgets de app.

Quando usar

  • ✓Quando um widget Glance na tela inicial mostra conteúdo antigo ou travado depois de uma sincronização em segundo plano.
  • ✓Quando você configura um widget do Android 17 e precisa manter as imagens dentro do limite de memória.
  • ✓Quando você mantém um AppWidgetProvider clássico e quer atualizá-lo corretamente.

Link da skill

https://github.com/android/skills/blob/main/system/glance-appwidget-updates-and-memory/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/system/glance-appwidget-updates-and-memory/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

“O meu widget Glance para de atualizar depois da sincronização em segundo plano. Corrija a atualização e mantenha as imagens pequenas.”

5 skills novas por semana. 1 minuto de leitura.

Como funciona

A skill verifica as configurações do build e do manifesto e depois reduz a resolução das imagens para o tamanho do widget. Também atualiza o estado do widget para que a tela inicial mostre o conteúdo mais recente.

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

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

Prerequisites

  • Kotlin Android project (minSdk >= 26) with compileSdk = 37 (targetSdk = 37 when targeting Android 17) in build.gradle.kts.
  • Jetpack Glance (1.2.0, minimum 1.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 existing namespace, 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_server computes the RemoteViews bitmap memory cap (6 * width * height bytes, or 1.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 to QHD+ 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 maxHeightDp in RGB_565 or ALPHA_8), and enforce the per-image byte ceiling (calculateWidgetMemoryCapBytes(context) / distinctImageCount) estimated as 6 * width * height from WindowManager.currentWindowMetrics.bounds on API 30+ (falling back to resources.displayMetrics on API 26-29 or if WindowManager is unavailable).
  • Decode shared bitmaps once outside provideContent : Both SizeMode.Exact (used by glance-canonical-layouts to compose the current span's portrait and landscape orientations) and SizeMode.Responsive (used to pre-bundle a set of DpSize breakpoints) invoke provideContent multiple times per update. Decode shared bitmaps once in provideGlance before provideContent and pass them to ImageProvider(bitmap) so RemoteViews deduplicates the shared Bitmap across all sizes in either mode. If a widget scales distinct bitmaps per LocalSize.current, divide calculateWidgetMemoryCapBytes(context) by the number of distinct bitmaps.
  • Downsample content URIs and grant launcher read permissions : On Android 17 (targetSdk >= 37), bitmap-backed Icons count toward the cap alongside Bitmaps. content:// URIs passed to ImageProvider(uri) or RemoteViews.setImageViewUri don't count toward the inter-process communication (IPC) cap, but the launcher decodes them at full resolution. Downsample the file into context.cacheDir, expose it with FileProvider.getUriForFile, and grant Intent.FLAG_GRANT_READ_URI_PERMISSION to Intent.CATEGORY_HOME packages.
  • Trigger explicit widget updates after state mutations : updateAppWidgetState writes preferences to DataStore without updating the widget UI. After you mutate state, call GlanceAppWidget.update(context, glanceId) or GlanceAppWidget.updateAll(context).
  • Use full updateAppWidget calls when you replace images : In AppWidgetProvider classes, when you replace bitmaps or Icons, call AppWidgetManager.updateAppWidget instead of partiallyUpdateAppWidget.

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:

Perguntas frequentes

Qual versão do Android ela tem como alvo?

Cobre os limites de memória de widgets do Android 17 (API 37) e as configurações necessárias para mirar essa versão.

Preciso do Glance?

A skill é feita para widgets Jetpack Glance, e também cobre widgets RemoteViews clássicos.

Ela desenha o layout do widget?

Os modelos de layout são tratados por uma skill separada de layouts canônicos.

Detalhes

Descrição original do 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

Popularidade

Estrelas no GitHub
10 mil
Posição no ranking
#11935
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