I'm taking a swing at quickly producing a fully fledged AppWidget that will
augment my forthcoming Daisy Chase game. I've encountered a couple of
issues.

There's one definite bug: AppWidgetProvider fails to
handle ACTION_APPWIDGET_DELETED actions properly. Browsing the source I can
see that AppWidgetService broadcasts an ACTION_APPWIDGET_DELETED Intent with
an EXTRA_APPWIDGET_ID, but the AppWidgetProvider is only looking
for EXTRA_APPWIDGET_IDS. The result is that you never receive a call
to onDeleted().

The workaround is simple: don't use AppWidgetProvider, but the question is
which end is wrong? Nothing is specified in the docs as far as I can tell.
Do we need to watch out for either extra for both updates and deletions?

Additionally (and I haven't investigated this yet) there appears to be a
possible deficiency in the timeliness of ACTION_APPWIDGET_UPDATED
broadcast cessation. If my debug output is to be believed, what I am seeing
is that the deletion is broadcast but I continue to receive update events
for the deleted widget until I add another widget from the same provider;
that is, I remove my widget on the home-screen and continue to receive
updates for it (indefinitely it seems) until I add another.
The second issue I've encountered probably isn't a bug, but I can't work out
the expected behaviour. My widgets contain an ImageView. The image is small
(80x80) and updates every hour. I decided that the most efficient approach
would be to write a ContentProvider that serves pngs of the widget images
from disk via openFile(). My RemoteViews for each widget then queues a
setImageURI call with the appropriate content URI.

This works up-to a point. The problem is that when the widget is updated and
a new image is generated, how can I kick the ImageView into reloading the
image? The obvious solution which I expected to work, was to push another
RemoteViews object (new instance - identical layout) to the AppWidgetManager
but that doesn't work. The image is not requested again. What is causing
this, over-aggressive optimization in the handling of RemoveViews by the
widget framework, or something else?

(Again the workaround is simple: decorate the Uri with something distinctive
like a timestamp so that the Uri is unique on each request.)

Tom

--~--~---------~--~----~------------~-------~--~----~
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