简体   繁体   English

正在执行BroadcastReceiver的onReceive代码中的延迟

[英]Delay in onReceive code of BroadcastReceiver being executed

I am using a BroadcastReceiver to monitor changes in network state, however there is a delay before the code in my onReceive is executed and i need it to be instant. 我正在使用BroadcastReceiver来监视网络状态的变化,但是在执行onReceive中的代码之前会有一个延迟,因此我需要它是即时的。 Any ideas as to what I should do? 关于我应该做什么的任何想法?

First check in your broadcast class you are not doing a heavy process which could delay your broadcast, dont forget to use an asynctask or thread in case of doing heavy work, second you could try to put the priority flag on the broadcast receiver in the manifest and put the value of 999 as maximum, depending the broadcast this could improve the performance. 首先检查广播类,您没有执行繁重的过程,这可能会延迟广播,别忘了在繁重的工作中使用asynctask或线程,其次,您可以尝试在清单中的广播接收器上放置优先级标志并将最大值999设置为最大值,这取决于广播,这可以提高性能。

android:priority="999" android:priority =“ 999”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM