Skip to content

Generated Previews API #359

@ash2moon

Description

@ash2moon

Problem to solve

Currently, Android widget previews are often static, using an image or a simple layout. This means the preview shown in the widget picker can be significantly different from how the widget actually looks when placed on the home screen.

The Android platform has introduced a "Generated Previews" feature, which allows apps to provide a dynamic RemoteViews object to serve as a more accurate, rich preview. This allows developers to show previews that better reflect the widget's final appearance and can even include personalized data.

Proposal

I propose adding functionality to the home_widget package to support the Generated Previews API on Android.

This would likely involve:

  1. Exposing a new method in the Dart API that allows developers to provide the necessary data for a preview.
  2. On the native Android side, this method would construct a RemoteViews object.
  3. The native code would then call the AppWidgetManager.setWidgetPreview method with the generated RemoteViews to update the widget's preview.

Since Jetpack Glance now supports generated previews, the implementation could consider using the GlanceAppWidgetManager.setWidgetPreviews API as a modern approach to providing this feature.

More information

Instructions: https://developer.android.com/develop/ui/compose/glance/generated-previews

Which Platform would be improved?

No response

Other

  • Are you interested in working on a PR for this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions