当我按下这个按钮时:
case R.id.btlento:
Timer timers = new Timer();
timers.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
cameraOn();
},deloy1,poriod1);
Timer timers2 = new Timer();
timers2.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
cameraOff();
}
},deloy,poriod);
方法 cameraOn 和 cameraOff 是:
private void cameraOff() {
// TODO Auto-generated method stub
parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
camera.setParameters(parameters);
camera.release();
camera = null;
}
private void cameraOn() {
// TODO Auto-generated method stub
camera = Camera.open();
parameters = camera.getParameters();
parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(parameters);
}
变量是:
int deloy = 2000;
int poriod = 2000;
int deloy1 = 1000;
int poriod1 = 2000;
这一切都是为了让相机闪光灯闪烁,但我不知道如何打破循环,因为永远不会停止。
我怎样才能停止循环?