I want my app to perform a task, in onCreate, once when the app is launched. But, in a random time interval. I want it to pick any time from 1-60 seconds.
currently I am using CountDownTimer
new CountDownTimer(20000, 10000) {
//currently time delay is 2000 milliseconds
@Override
public void onFinish() {
// TODO Auto-generated method stub
runOnUiThread(new Runnable() {
@Override
public void run() {
// do your task here
Toast.makeText(getBaseContext(), "x", Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onTick(long millisUntilFinished) {
}
}.start();
but this is pre-defined, not random. How do I make one?