From what thread are you ultimately calling

AppWidgetManager.updateAppWidget

?

It has to be the UI thread, I think you should check to make sure.

-- Kostya

14.07.2010 16:35, TjerkW пишет:
Works on the emulator.. but on my nexus one i still get the nasty
nullpointerexception deep inside the Android apis


07-14 14:33:53.105: ERROR/HyvesWidgetService(13806): Failed updating
widget: 68, due to java.lang.NullPointerException
07-14 14:33:53.105: WARN/System.err(13806):
java.lang.NullPointerException
07-14 14:33:53.115: WARN/System.err(13806):     at
android.widget.RemoteViews
$ReflectionAction.writeToParcel(RemoteViews.java:399)
07-14 14:33:53.115: WARN/System.err(13806):     at
android.widget.RemoteViews.writeToParcel(RemoteViews.java:1003)
07-14 14:33:53.115: WARN/System.err(13806):     at
com.android.internal.appwidget.IAppWidgetService$Stub
$Proxy.updateAppWidgetIds(IAppWidgetService.java:374)
07-14 14:33:53.125: WARN/System.err(13806):     at
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
246)
07-14 14:33:53.125: WARN/System.err(13806):     at
android.appwidget.AppWidgetManager.updateAppWidget(AppWidgetManager.java:
265)
07-14 14:33:53.125: WARN/System.err(13806):     at
com.hyves.android.widget.HyvesWidgetProvider.updateAppWidget(HyvesWidgetProvider.java:
75)
07-14 14:33:53.135: WARN/System.err(13806):     at
com.hyves.android.widget.HyvesWidgetService.onHandleIntent(HyvesWidgetService.java:
115)
07-14 14:33:53.135: WARN/System.err(13806):     at
android.app.IntentService
$ServiceHandler.handleMessage(IntentService.java:59)
07-14 14:33:53.145: WARN/System.err(13806):     at
android.os.Handler.dispatchMessage(Handler.java:99)
07-14 14:33:53.145: WARN/System.err(13806):     at
android.os.Looper.loop(Looper.java:123)


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!


--
Kostya Vasilev -- WiFi Manager + pretty widget -- http://kmansoft.wordpress.com

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