How can an AsyncTask be started after a 3 second delay?
Using handlers as suggested in the other answers, the actual code is:
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
new MyAsyncTask().execute();
}
}, 3000);
You can use Handler for that. Use postDelayed(Runnable, long) for that.
Handler#postDelayed(Runnable, Long)
You can use this piece of code to run after a 3 sec delay.
new Timer().schedule(new TimerTask() {
@Override
public void run() {
// run AsyncTask here.
}
}, 3000);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With