我扩展了 BroadcastReceiver
,在 onReceive()
中我做任何我需要做的事情。
onReceive()
有一个超时,来自文档:
there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed
当我处于 Debug模式时,这会产生问题。我需要超过 10 秒(有时)。如果我没有在 10 秒内完成所有调试,我的连接将关闭并且调试将停止。
我可以增加超时或出于调试目的禁用它吗?
谢谢。
最佳答案
为了防止您的应用程序在调试过程中暂停在断点时强制关闭,请尝试安装开发工具应用程序并启用调试应用程序设置:
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.
所有详细信息都在这里:http://developer.android.com/tools/debugging/debugging-devtools.html
如果您在onReceive
方法中做一些复杂的事情,那么请考虑让您的BroadcastReceiver
启动一个Service。并传递它从 onReceive
中获取的数据。 Service
然后可以进行更长的处理。
关于android - BroadcastReceiver onReceive超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4650016/