我正在使用 adb/android 工具等在 eclipse 中的模拟器上编写一个应用程序。当我在下面调试我的广播接收器代码时,在代码的某个部分中,当我在那里停留几秒钟时,调试器会分离。
它没有给我足够的时间来调试和断开连接,
错误就像
- 03-01 20:42:38.293: I/CallListener(320): onReceive.. 03-01 20:42:48.319: W/ActivityManager(59): 广播
广播记录超时{45098250 android.intent.action.PHONE_STATE} -
接收器=android.os.BinderProxy@450d2070 03-01 20:42:48.319:
W/ActivityManager(59):超时期间的接收器:ResolveInfo{45032058
mahmed.net.apps.CallListener p=0 o=0 m=0x108000} 03 -01 20:42:48.353:
I/Process(59):发送信号。PID: 320 SIG: 3 03-01 20:42:48.353:
I/dalvikvm(320): threadid=3: 响应信号 3 03-01 20:42:48.353: I/dalvikvm(320): 将堆栈跟踪写入'/data/anr/traces.txt' 03-01
20:42:48.362: I/Process(59): 发送信号。PID: 59 SIG: 3 03-01
20:42:48.362: I/dalvikvm(59): threadid=3: 对信号 3 做出反应
调试器断开连接的部分是
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
}
broadcastreceiver 的完整代码是这样的:
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
}
}
}
更多在