0% found this document useful (0 votes)
147 views

Android 4.4: Camera Flashlight Blinks Only Few Number of Times

The document is a question posted on Stack Overflow asking for help with an Android camera flashlight app that blinks the flashlight only a few times before crashing. The code for the app is provided in links. Responses suggest modifying the code to wrap the blinking logic in a new thread to improve performance and prevent crashing. A sample blinking flashlight app is also provided as a reference.

Uploaded by

search009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
147 views

Android 4.4: Camera Flashlight Blinks Only Few Number of Times

The document is a question posted on Stack Overflow asking for help with an Android camera flashlight app that blinks the flashlight only a few times before crashing. The code for the app is provided in links. Responses suggest modifying the code to wrap the blinking logic in a new thread to improve performance and prevent crashing. A sample blinking flashlight app is also provided as a reference.

Uploaded by

search009
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

login

tour

signup

help

StackOverflowisaquestionandanswersiteforprofessionalandenthusiastprogrammers.It's100%free,no
registrationrequired.

stackoverflowcareers

Takethe2minutetour

Android4.4:CameraFlashlightblinksonlyfewnumberoftimes

Ihavelookedintoothercameraflashlightrelatedproblemsinstackoverflow,butcouldn'tfindananswerthatsolvesmyissue.Theflashlight
flashesfor68timesandthentheappcrashes.HereIhavea blink() methodthatcalls cameraon() and cameraoff() inaloop.Couldyou
pleaseletmeknowwhereIwentwrong?Mycodecanbefoundhere:http://pastebin.com/3LRMwd1J Thelogcatoutputcanbeseehere:
http://pastebin.com/2GTpn8Ux
Ihavetriedusingsurfacetextures,triedtoinclude Thread.sleep() inbetween cameraon() and cameraoff() butsofarnoluck.
IuseAndroid4.4withlatestsdkandjdkversions.Iusenexus5fortesting.
Thanksinadvance!
android flashlight

editedJul30'14at13:51

askedJul30'14at13:19
user3891554
1

Pleasepostyourcodeinyourquestionaswell,someareunabletogettopastebinduetoproxies JBires
Jul30'14at13:52

3Answers

Seeifmycodehelpsany:https://github.com/wolfhorse/SimpleFlashlight
Itdoesn'tblinkbutitmaybeagoodreferenceforyou.
EDIT:ImodifiedtheonClick()eventofthetogglebuttonintheSimpleFlashlightappreferenced
abovebyaddingthecodebelowanditblinks/flashesfineonmySamsungGalaxyS5without
error.
Threadthread=newThread(newRunnable(){
@Override
publicvoidrun(){
booleanflashOn=false;
for(inti=0;i<20;i++){
flashOn=!flashOn;
toggleFlash(flashOn);
try{
Thread.sleep(300);
}catch(InterruptedExceptione){
e.printStackTrace();
}
}
}
});
thread.start();

WrappedinnewThreadlikeotherssuggestedherebetterperformance.
editedAug5'14at20:13

answeredJul30'14at14:28
wolfhorse
46

Thankswillcheckthatout! user3891554 Jul31'14at10:13


SeemslikeyoushouldbeabletomodifythatprojectandcallthetoggleFlash(booleanturnLightOn)[located
intheSimpleFlashlight/app/src/main/java/com/wolfhorse/simpleflashlight/FlashlightActivity.java
file]usingaBlink()methodlikeyouareattemptingabove.Letmeknowifitworks.wolfhorseJul31'14at
20:28
Itdoesn'twork:(Iwasnotabletofindouttheerror user3891554 Aug1'14at9:52

You might also like