简体   繁体   中英

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. 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.

android:priority="999"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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