Okay am i now using a IntentService without a thread

But now i get an ANR on a broadcast:

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}
07-14 13:38:49.523: INFO/Process(59): Sending signal. PID: 309 SIG: 3
07-14 13:38:49.523: INFO/dalvikvm(309): threadid=3: reacting to signal
3
07-14 13:38:49.732: INFO/dalvikvm(309): Wrote stack traces to '/data/
anr/traces.txt'
07-14 13:38:49.732: INFO/Process(59): Sending signal. PID: 59 SIG: 3
07-14 13:38:49.732: INFO/dalvikvm(59): threadid=3: reacting to signal
3
07-14 13:38:49.953: INFO/dalvikvm(59): Wrote stack traces to '/data/
anr/traces.txt'
07-14 13:38:49.953: INFO/Process(59): Sending signal. PID: 105 SIG: 3
07-14 13:38:49.953: INFO/dalvikvm(105): threadid=3: reacting to signal
3
07-14 13:38:50.013: INFO/dalvikvm(105): Wrote stack traces to '/data/
anr/traces.txt'
07-14 13:38:50.023: INFO/Process(59): Sending signal. PID: 116 SIG: 3
07-14 13:38:50.023: INFO/dalvikvm(116): threadid=3: reacting to signal
3
07-14 13:38:50.033: INFO/dalvikvm(116): Wrote stack traces to '/data/
anr/traces.txt'
07-14 13:38:50.043: INFO/Process(59): Sending signal. PID: 121 SIG: 3
07-14 13:38:50.043: INFO/dalvikvm(121): threadid=3: reacting to signal
3
07-14 13:38:50.073: INFO/dalvikvm(121): Wrote stack traces to '/data/
anr/traces.txt'
07-14 13:38:50.083: INFO/Process(59): Sending signal. PID: 295 SIG: 3
07-14 13:38:50.083: INFO/dalvikvm(295): threadid=3: reacting to signal
3
07-14 13:38:50.303: INFO/Process(59): Sending signal. PID: 219 SIG: 3
07-14 13:38:50.323: INFO/dalvikvm(219): threadid=3: reacting to signal
3
07-14 13:38:50.503: INFO/Process(59): Sending signal. PID: 171 SIG: 3
07-14 13:38:50.703: INFO/Process(59): Sending signal. PID: 238 SIG: 3
07-14 13:38:50.733: INFO/dalvikvm(238): threadid=3: reacting to signal
3
07-14 13:38:50.903: INFO/Process(59): Sending signal. PID: 260 SIG: 3
07-14 13:38:51.113: INFO/Process(59): Sending signal. PID: 272 SIG: 3
07-14 13:38:51.213: INFO/dalvikvm(272): threadid=3: reacting to signal
3
07-14 13:38:51.313: INFO/Process(59): Sending signal. PID: 203 SIG: 3
07-14 13:38:51.522: INFO/Process(59): Sending signal. PID: 194 SIG: 3
07-14 13:38:51.633: INFO/dalvikvm(194): threadid=3: reacting to signal
3
07-14 13:38:51.723: INFO/Process(59): Sending signal. PID: 248 SIG: 3
07-14 13:38:51.883: INFO/dalvikvm(248): threadid=3: reacting to signal
3
07-14 13:38:51.913: INFO/dalvikvm(171): threadid=3: reacting to signal
3
07-14 13:38:51.923: INFO/Process(59): Sending signal. PID: 110 SIG: 3
07-14 13:38:51.923: INFO/dalvikvm(110): threadid=3: reacting to signal
3
07-14 13:38:51.983: INFO/dalvikvm(110): Wrote stack traces to '/data/
anr/traces.txt'
07-14 13:38:51.993: INFO/Process(59): Sending signal. PID: 210 SIG: 3
07-14 13:38:52.053: DEBUG/dalvikvm(309): GC_FOR_MALLOC freed 4504
objects / 509560 bytes in 177ms
07-14 13:38:52.092: INFO/dalvikvm(210): threadid=3: reacting to signal
3
07-14 13:38:52.302: ERROR/ActivityManager(59): ANR in
com.hyves.android.application
07-14 13:38:52.302: ERROR/ActivityManager(59): Reason: Broadcast of
Intent { act=android.appwidget.action.APPWIDGET_ENABLED
cmp=com.hyves.android.application/
com.hyves.android.widget.HyvesWidgetProvider }
07-14 13:38:52.302: ERROR/ActivityManager(59): Load: 3.16 / 1.11 /
0.39
07-14 13:38:52.302: ERROR/ActivityManager(59): CPU usage from 17434ms
to 101ms ago:
07-14 13:38:52.302: ERROR/ActivityManager(59):   zygote: 77% = 75%
user + 2% kernel / faults: 2350 minor 56 major
07-14 13:38:52.302: ERROR/ActivityManager(59):   system_server: 11% =
9% user + 2% kernel / faults: 2144 minor 23 major
07-14 13:38:52.302: ERROR/ActivityManager(59):   ndroid.settings: 5% =
1% user + 3% kernel / faults: 4591 minor 111 major
07-14 13:38:52.302: ERROR/ActivityManager(59):   ndroid.launcher: 1% =
0% user + 1% kernel / faults: 1212 minor 11 major
07-14 13:38:52.302: ERROR/ActivityManager(59):   adbd: 0% = 0% user +
0% kernel / faults: 30 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   m.android.phone: 0% =
0% user + 0% kernel / faults: 315 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   putmethod.latin: 0% =
0% user + 0% kernel / faults: 245 minor 1 major
07-14 13:38:52.302: ERROR/ActivityManager(59):   logcat: 0% = 0% user
+ 0% kernel / faults: 57 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   com.svox.pico: 0% =
0% user + 0% kernel / faults: 192 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   e.process.gapps: 0% =
0% user + 0% kernel / faults: 54 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   roid.alarmclock: 0% =
0% user + 0% kernel / faults: 153 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   com.android.mms: 0% =
0% user + 0% kernel / faults: 148 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   d.process.media: 0% =
0% user + 0% kernel / faults: 126 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   s:FriendService: 0% =
0% user + 0% kernel / faults: 133 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):   m.android.music: 0% =
0% user + 0% kernel / faults: 122 minor
07-14 13:38:52.302: ERROR/ActivityManager(59):  -zygote: 0% = 0% user
+ 0% kernel


Here is my code in the AppWidgetProvider class:


    @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));
    }

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.


On Jul 14, 12:58 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> On Wed, Jul 14, 2010 at 4:37 AM, TjerkW <tje...@gmail.com> wrote:
> > Basically i have an AppWidgetProvider which starts a Service on
> > update. That service starts a thread and at the end it updates the
> > widget by calling AppWidgetManager.updateAppWidget.
>
> Turn the Service into an IntentService, and get rid of your own
> thread. IntentService gives you your work on a background thread
> automatically. See:
>
> http://github.com/commonsguy/cw-advandroid/tree/master/AppWidget/Micr...
>
> > But i get a NullPointerException? What am i doing wrong? The Service
> > is not in a different process..
>
> That is impossible to say without seeing your code.
>
> --
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to