关于 Android 的ANR in XXX.XXX.xxx ,Reason: Broadcast of Intent

来源:互联网 发布:淘宝客申请高佣金api 编辑:程序博客网 时间:2024/06/01 20:08

引起这个错误的原因是,在一个BroadcastReceiver中的onReceive方法中的处理不能超过10秒,如果超过就会出现ANR错误。

所有尽量不要在onReceive中做耗时的处理,最好用Service来处理。(不要另外开启线程,因为这个线程会随着onReceive的返回而终止。)

以下在Google API中的原文:

so you should
never perform long-running operations in it (there is a timeout of 10 seconds that the system allows

before considering the receiver to be blocked and
a candidate to be killed). You cannot launch a popup dialog in your

implementation of onReceive().

原创粉丝点击