Peter Jeffe wrote:
> When our app gets updated sometimes the buttons on existing widgets
> get the wrong icon drawables, and sometimes the layout itself is
> broken.  I believe this is because the update has different values for
> some of the drawable and other resources, since they're generated
> alphabetically, but the widget host still retains the old ids.  A
> delete and re-create of the widget fixes the problem, but a number of
> users get confused by it and of course it just looks bad.
> 
> Is there something I should be doing to prevent this?  If not are
> there any workarounds, other than making all the resources used by
> widgets start with "0" or something equally ugly?

WARNING: the following is purely hypothetical and has not been tried by
the author. Also, there may be simpler solutions. Tests have shown that
following the author's advice causes rats in cancer laboratories. You
have been warned!

---------------------

In theory, you can watch for ACTION_PACKAGE_REPLACED to find when your
app has been upgraded. You'd need to watch for your UID in the
EXTRA_UID, and you'd get that UID from PackageManager (or perhaps
someplace simpler -- not sure if there's a convenience method for that
somewhere...).

If you can get that working, then you can try one of two approaches to
refreshing the app widget.

First, it may be that pushing out a regular update to the RemoteViews
will suffice, no different than your regular app widget update process.

If that is insufficient, you can probably achieve a similar end by
pushing out an update with a totally different layout (e.g., an empty
one) and, milliseconds later, pushing out a regular update back to your
desired layout. You could use AlarmManager to schedule the second update.

As the WARNING suggests, your mileage may vary. Unless you are from
outside of the US, in which case your kilometerage may vary.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android App Developer Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to