I have 4 int for time
int delay;
int period;
int delay1;
int period1;
they are taking control of these methods:
cameraOn();
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
cameraOff();
}
},delay1,period1);
Timer timer2 = new Timer();
timer2.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
cameraOn();
}
},delay,period);
}
These methods are doing the flash camera blink all the time, and what I want is with two buttons I have, change the speed of the blink, now they’re like this:
case R.id.btslow:
delay = 2400;
period = 2400;
delay1 = 1200;
period1 = 2400;
break;
case R.id.btfast:
delay = 600;
period = 600;
delay1 = 300;
period1 = 600;
break;
but they dont change the speed of the blink, how can I do it? Because if give them some valor from the begining later they don’t change when I press the buttons. Thanks!!
Changing the variables won’t change the interval and delay of the current scheduled tasks, try this: https://stackoverflow.com/a/3871723/1333516