Zsolt,

17.09.2010 2:33, Zsolt Vasvari пишет:
Ok thanks, see below for my comments.

On Sep 16, 6:15 pm, Kostya Vasilyev<[email protected]>  wrote:
OnUpdate runs on the UI thread. I can see two ways to solve the concurrency
issue:

- Use a service for updating the widget, consider using an IntentService for
database queries so they run on a worker thread - updating a widget can
supposedly be done from any thread, although I personally haven't done it.
How does this help exactly with the concurrency issue?  Not trying to
be snarky, I just truly don't understand.

You indicated that querying data for the widget in your code could be a lengthy operation. By running it on a background thread, you'd avoid ANR's when onUpdate is called.

I want to avoid this.  The widget's data computation involves heavy
database stuff, and a lot of things in my app can effect the final
result.  I would have to sprinkle a bunch of logic all over my app to
handle all cases and even then, it would be pretty slow.  So I thought
I'd just use periodic update mechanism.

Can I tell the AppWidgetManager that I am busy and come back to me in
lets say 5 minutes?

Yes and no. Nothing built into the app widget framework, but still this could be done. Use AlarmManager in onUpdate to schedule a pending intent delayed by the desired amount of time. You could add its action to the AppWidgetProvider in the manifest (in addition to APPWIDGET_UPDATE) so all widget-related logic is in one class.

This is really a fancy way of polling, so personally I don't like it too much, but then again - it's your application.

-- Kostya

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