BroadcastReceiver使用系统注册:在 AndroidManifest.xml 中注册 public void onReceive(Context context, Intent intent) {
try {
Thread.sleep(1);
Log.i("mytag", "44444444444");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
中会有ANR错误报出如果使用代码中注册: IntentFilter intentFilter = new IntentFilter( "android.provider.Telephony.SMS_RECEIVED " );
registerReceiver( mBatteryInfoReceiver , intentFilter); 在public void onReceive(Context context, Intent intent) 超时了 就没有ANR错误
这个是为什么?
try {
Thread.sleep(1);
Log.i("mytag", "44444444444");
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
中会有ANR错误报出如果使用代码中注册: IntentFilter intentFilter = new IntentFilter( "android.provider.Telephony.SMS_RECEIVED " );
registerReceiver( mBatteryInfoReceiver , intentFilter); 在public void onReceive(Context context, Intent intent) 超时了 就没有ANR错误
这个是为什么?
解决方案 »
- 急!如何在jar包中引用外部工程的资源文件
- 在Handler中 怎么重新启动 Activity???????
- 关于Unexcepted stop
- 求解答:error: Error parsing XML: unbound prefix
- 达人帮忙!点击某个activity区域外的部分实现关闭该activity如何实现?
- 在eclipse里引用android出错,怎么办?
- 关于调用google map的问题!!!!
- Tabhost,点击tab时修改tabhost里面的布局
- 请问在android上如何实现透明相机
- Eclipse working set里的项目文件不见了!!求帮忙看下
- AlertDialog.Builder listview SimpleCursorAdapter删除项问题
- Android平台下三维应用的开发技术有哪些?
是Thread.sleep(10000);
Since: API Level 1Register a BroadcastReceiver to be run in the main activity thread. The receiver will be called with any broadcast Intent that matches filter, in the main application thread. LZ可以把时间改大一点试试,我自己也测试了下,是要报ANR滴咯
这是神马情况,休眠1ms,为嘛?呵呵....
private ServiceRecord mService; void setService(ServiceRecord service) {
mService = service;
} public void run() {
synchronized(ActivityManagerService.this) {
performServiceRestartLocked(mService);
}
}
}