Reputation: 15039
I am writing an app on simulator in eclipse with adb/android tools etc. While I am debugging my broadcastreceiver code below, in a certain section of the code the debugger gets detached while I stay there for few seconds..
It does not give me enough time to debug and disconnects,
errors are like
- 03-01 20:42:38.293: I/CallListener(320): onReceive.. 03-01 20:42:48.319: W/ActivityManager(59): Timeout of broadcast
BroadcastRecord{45098250 android.intent.action.PHONE_STATE} -
receiver=android.os.BinderProxy@450d2070 03-01 20:42:48.319:
W/ActivityManager(59): Receiver during timeout: ResolveInfo{45032058
mahmed.net.apps.CallListener p=0 o=0 m=0x108000} 03-01 20:42:48.353:
I/Process(59): Sending signal. PID: 320 SIG: 3 03-01 20:42:48.353:
I/dalvikvm(320): threadid=3: reacting to signal 3 03-01 20:42:48.353: I/dalvikvm(320): Wrote stack traces to '/data/anr/traces.txt' 03-01
20:42:48.362: I/Process(59): Sending signal. PID: 59 SIG: 3 03-01
20:42:48.362: I/dalvikvm(59): threadid=3: reacting to signal 3
The section where the debugger gets disconnected is
if (newCallState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
{
Utils.log(TAG, "off hook...");
// Do necessary work to start off a service etc ..
// If I debug here for few seconds the debugger gets detached.. without any errors
}
The full code of broadcastreceiver is like this:
public class CallListener extends BroadcastReceiver
{
Context m_context;
/**
* Called on application thread
*/
@Override
public void onReceive(Context context, Intent intent)
{
Utils.log(TAG, "onReceive..");
m_context = context;
String strAction = intent.getAction();
Assert.assertNotNull(strAction);
if(strAction.equals(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED))
{
handleCallStateChanged(context, intent);
}
}
private void handleCallStateChanged(Context context, Intent intent)
{
Utils.log(TAG, "handling call state changed");
String newCallState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
if (newCallState.equals(TelephonyManager.EXTRA_STATE_OFFHOOK))
{
Utils.log(TAG, "off hook...");
// Do necessary work to start off a service etc ..
// If I debug here for few seconds the debugger gets detached.. without any errors
}
}
}
more in
Upvotes: 3
Views: 3439
Reputation: 5119
There was a thread with the same issue: BroadcastReceiver onReceive timeout
Copy/Paste
In order to prevent your app from force closing while you are paused on a break point during debugging, try installing the Dev Tools application and enable the Debug App setting which:
Lets you select the application to debug. You do not need to set this to attach a debugger, but setting this value has two effects:
It will prevent Android from throwing an error if you pause on a breakpoint for a long time while debugging.
All of the details are here:
http://developer.android.com/guide/developing/debug-tasks.html#additionaldebuggingIf you are doing something complicated in your onReceive method, then consider having your BroadcastReceiver start a Service and pass along the data it gets from within onReceive. The Service can then do the longer processing.
The link to the developer doc from google was broken Here you have it: http://developer.android.com/tools/debugging/debugging-devtools.html
Upvotes: 2