i am using timer like:
Timer timer = new Timer();
timer.scheduleAtFixedRate(new CheckWifi(), 0, 50000); // 5 seconds
class Wifi extends BroadcastReceiver {
protected class CheckWifi extends TimerTask {
@Override
public void run() {
}
}
but CheckWifi class is executed in a second not after 50 second like is set in scheduleAtFixedRate. Why?
Is it better to use Runnable instead of Timer?
You’ll have to use:
The second parameter specifies the delay before the first execution.
The third parameter specifies the delay between subsequent executions.