Android intent takes a long time to be received

4.8k views Asked by At

In my app I am sending an intent to update an appWidget. The problem is, from the logcat I can see that the intent is taking on average ten seconds to be received.

 05-16 18:12:54.070: DEBUG/PHCA_Variable(7580): Broadcast sent  
 05-16 18:12:54.080: INFO/ActivityManager(274): Starting: Intent { flg=0x10000000 cmp=com.skipmorrow.phca/.WidgetDialogResponseActivity (has extras) } from pid 7580    
 05-16 18:12:54.100: WARN/ActivityManager(274): Trying to launch com.skipmorrow.phca/.WidgetDialogResponseActivity  
 05-16 18:12:54.170: DEBUG/InputTransport(274): Input channel constructed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (server)', ashmemFd=299, receivePipeFd=311, sendPipeFd=310   
 05-16 18:12:54.170: DEBUG/InputTransport(274): Input channel constructed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=304, receivePipeFd=309, sendPipeFd=313   
 05-16 18:12:54.170: DEBUG/InputTransport(274): Input channel destroyed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=304, receivePipeFd=309, sendPipeFd=313 
 05-16 18:12:54.180: DEBUG/InputTransport(7580): Input channel constructed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=66, receivePipeFd=67, sendPipeFd=68 
 05-16 18:12:54.460: INFO/ActivityManager(274): Displayed com.skipmorrow.phca/.WidgetDialogResponseActivity: +362ms 
 05-16 18:12:56.140: INFO/InputDispatcher(274): Delivering key to current input target: action: 0, channel '40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (server)' 
 05-16 18:12:56.260: INFO/InputDispatcher(274): Delivering key to current input target: action: 1, channel '40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (server)' 
 05-16 18:12:56.390: DEBUG/InputTransport(7580): Input channel destroyed: name='40832a98 com.skipmorrow.phca/com.skipmorrow.phca.WidgetDialogResponseActivity (client)', ashmemFd=66, receivePipeFd=67, sendPipeFd=68   
 05-16 18:13:03.350: DEBUG/PHCA_PhcaAppWidgetProvider(7580): onReceive(); action = android.appwidget.action.APPWIDGET_UPDATE    

The only thing I see that looks a little fishy is a warning that an activity is starting. Why would that be a warning? Other than that, everything seems ok.

The code to send the intent is nothing special:

    Log.d(MY_DEBUG_TAG, "UpdateAppWidgets()");
    Intent i = new Intent();
    i.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    ComponentName phcaWidget = new ComponentName(ctx, PhcaAppWidgetProvider.class);
    i.putExtra("appWidgetIds", AppWidgetManager.getInstance(ctx).getAppWidgetIds(phcaWidget));

    ctx.sendBroadcast(i);
    Log.d(MY_DEBUG_TAG, "Broadcast sent");

And the onReceive in the appWidgetProvider is nothing special either. The Log statement is the first command.

What could cause an intent to take upwards of ten seconds to be received?

Skip

1

There are 1 answers

2
mwengler On

If the Activity you are sending the intent to does not yet exist, it has to be started. 10 seconds seems like a long time for starting an app, but not insane.

I have apps which run 5 times or more slower when in debug mode. If you are in debug mode, it could be that it will run much faster if not in debug mode. Generally, you can see logcat messages when not in debug mode, for a device connected to PC running eclipse IDE. If you can get that working, you should try running that way and see if it is faster. Also try running with phone unplugged from Eclipse entirely, it will be harder to tell if its faster but it might be.