java - Flashlight blink on button click in android -




i developing flashlight application in trying add blink functionality on button click. code found is:

string mystring = "0101010101"; long blinkdelay 50; //delay in ms (int = 0; < mystring.length(); i++) {    if (mystring.charat(i) == '0') {       params.setflashmode(parameters.flash_mode_on);    } else {       params.setflashmode(parameters.flash_mode_off);    }    try {       thread.sleep(blinkdelay);    } catch (interruptedexception e) {       e.printstacktrace();    } } 

but code turns off flashlight after few blinks. how can start flashlight blink on button click , stop unless click again? help?

it's controlled string length loop break after count of becomes greater last index. use while loop if want blink flash continuously. can use 1 boolean variable switch between on off. , boolean in while condition break loop when button clicked





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -