androidandroid-jetpack-composeandroid-widgetglance-appwidget

Update existing Android widget to Glance Compose


I'm trying to migrate an existing Android widget to use Glance Compose, but haven't been able to find any documentation or answers on if it's possible to make it so that users with my existing widget already on their device will automatically get updated to the new Glance Compose version of my widget? Or is there no way to do this and users will have to manually add the new widget themselves again to their device?

I've read through the Android Glance compose docs but saw nothing around migrating existing widgets. I also tried just setting android:name of the glance compose widget to match the existing widget which makes it so that the widget stays on the users home screen but it doesn't seem to be getting updated to the glance compose version of the widget.


Solution

  • For the moment it is not possible to migrate automatically the old widget to the Glance version.

    A ticket is open at Google : https://issuetracker.google.com/issues/294137086

    In my case, the old widget is deleted when I install a new version of the app with the Glance. The only way that I find, is to store the data from the old widget (Data Base, Share pref...). And when the user wants to create the new widget (Glance version), I get the data from the old widget and I display them directly after the creation.