mercredi 7 juin 2017

How to schedule a random timing (every random minutes) event

I'm developing an Android App, I'm trying to manage a Vibration event. I need to schedule it every random minutes when a switch is checked. I have been using this code:

int delay3 = (60 + new Random().nextInt(60)) * 1000;

timer3.schedule(timerTask3, 0, delay3);

but the timer doesn't change delay3 until the switch is unchecked and checked again. Is there a way to schedule the event at random timing i.e. delay3 should change every time the task is running without unchecking the switch ?

thanks




Aucun commentaire:

Enregistrer un commentaire