androidandroid-widgetandroid-appwidgetappwidgetprovider

How to migrate old widgets into a new one


The app I am wrorking on has three widgets right now. Each of these widgets has a different size and a fix layout file. Now I've developed a new widget which is resizable and adaptive. It loads a fitting layoutfile according to its size.

Now with the next update with my app I would like to achieve the following:

  1. List only the new adaptive widget in the widget drawer, so the old widgets cannot be created
  2. Already existing widgets shall use the logic of the new widget to update their views

Right now I think that these two goals contradict each other. When I delete or disable the widget receiver from the manifest the widget disappears from the widget drawer but on the same time the existing widget on the homescreen breaks.

When I let the existing widget provider use the new logic the old widgets behave like the new one but on the widget drawer I've got four times the same widget.

Is there a way to achieve my goals? If not, is it possible to hide the old widgets for new users while they will be there for extings users who are updating their app?

Thanks a lot for your answers!


Solution

  • There is no solution to this. When you move the package name of the widget provider the widget gets deleted.

    I settled on using one provider of my old widgets which got migrated to the new one. The other three were deleted.