timer - Flashing mode in Android Flashlight app -
as can see i'm making flashlight android has 2 modes of flashing(first make led flashing non-stop, second make 0.5 second pause between flashes), code doesn't work. here code:
private void turnonflash() { if (!isflashon) { if (camera == null || params == null) { return; } params = camera.getparameters(); switch(mode) { case 1: params.setflashmode(parameters.flash_mode_torch); break; case 2: timer = new countdowntimer(1000, 500) { @override public void ontick(long millisuntilfinished) { params.setflashmode(parameters.flash_mode_torch); } @override public void onfinish() { params.setflashmode(parameters.flash_mode_off); } }; break; } camera.setparameters(params); camera.startpreview(); isflashon = true; playsound(); togglebuttonimage(); } }
and here method in mode detected
tvmode.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { switch(mode) { case 1: mode = 2; tvmode.settext("2"); if(isflashon) { turnoffflash(); turnonflash(); } break; case 2: mode = 1; tvmode.settext("1"); if(isflashon) { turnoffflash(); turnonflash(); } break; } } }); }
problem solved. forgot put .start();
on end of countdowntimer.
Comments
Post a Comment