How to broadcast and receive every 5 seconds?
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.
精彩评论