开发者

How to broadcast and receive every 5 seconds?

开发者 https://www.devze.com 2023-03-10 23:45 出处:网络
Basically I want to broadcast and receive every 5 seconds using this code: private final BroadcastReceiver checkWifiStateChanged = new BroadcastReceiver() {

Basically I want to broadcast and receive every 5 seconds using this code:

    private final BroadcastReceiver checkWifiStateChanged = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {    
            checkWifiSt开发者_高级运维ateHasChanged();

        }
    };

How could I do this?


As the comments have stated, this is basically an unnecessary way to approach this. The Android platform automatically sends out Intents for certain changes, and Wifi status is one of them. You need only have a BroadcastReceiver registered that filters on that Intent to be able to respond to it.

0

精彩评论

暂无评论...
验证码 换一张
取 消