Request update is a very fast method
/**
* Request updates for the given widgets. Will only queue them up,
you are
* still responsible for starting a processing thread if needed,
usually by
* starting the parent service.
*/
public static void requestUpdate(int[] appWidgetIds) {
synchronized (lock) {
for (int appWidgetId : appWidgetIds) {
HyvesWidgetService.appWidgetIds.add(appWidgetId);
}
}
}
Yeah the onUpdate (may) fork antother thread.
I now solved it by waiting in the IntentService thread on an object
using a lock:
lock.wait();
and then if it is done i call lock.notify().
This should work i think... i'm trying it out right now.
On Jul 14, 2:00 pm, Mark Murphy <[email protected]> wrote:
> On Wed, Jul 14, 2010 at 7:44 AM, TjerkW <[email protected]> wrote:
> > 07-14 13:38:49.503: WARN/ActivityManager(59): Timeout of broadcast
> > BroadcastRecord{43f724c0 android.appwidget.action.APPWIDGET_ENABLED} -
> > receiver=android.os.binderpr...@43deed00
> > 07-14 13:38:49.513: WARN/ActivityManager(59): Receiver during timeout:
> > ResolveInfo{43f72438 com.hyves.android.widget.HyvesWidgetProvider p=0
> > o=0 m=0x0}
> > �...@override
> > public void onUpdate(Context context, AppWidgetManager manager,
> > int[] appWidgetIds) {
> > log("onUpdate");
> > // If no specific widgets requested, collect list of all
> > if (appWidgetIds == null) {
> > appWidgetIds = manager.getAppWidgetIds(
> > new ComponentName(context,
> > HyvesWidgetProvider.class));
> > }
>
> > // Request update for these widgets and launch updater service
> > HyvesWidgetService.requestUpdate(appWidgetIds);
> > context.startService(new Intent(context,
> > HyvesWidgetService.class));
> > }
>
> I have no idea what:
>
> HyvesWidgetService.requestUpdate(appWidgetIds);
>
> does, but that would seem to be taking too long.
>
>
>
>
>
>
>
> > And code from the IntentService
>
> > /**
> > * Start this service, creating a background processing thread, if
> > not
> > * already running. If started with {...@link #ACTION_UPDATE_ALL},
> > will
> > * automatically add all widgets to the requested update queue.
> > */
> > �...@override
> > protected void onHandleIntent(Intent intent) {
> > // If requested, trigger update of all widgets
> > if (ACTION_UPDATE_ALL.equals(intent.getAction())) {
>
> > AppWidgetManager manager =
> > AppWidgetManager.getInstance(this);
> > Log.d(TAG, "Requested UPDATE_ALL action");
> > requestUpdate(manager.getAppWidgetIds(new
> > ComponentName(this, HyvesWidgetProvider.class)));
> > }
>
> > onUpdate();
> > }
>
> > onUpdate calls an asynchronous api call, and a callback updates tthe
> > widget.
>
> Wait, whoa, what? You are already in a background thread. Is
> onUpdate() forking yet another thread?
>
> --
> Mark Murphy (a Commons
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to *Advanced* Android Development_ Version 1.9
> Available!
--
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