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

      引起这个错误的原因是,在一个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().

没有更多推荐了,返回首页