• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

FlashLight that uses Camera Flash

What mechanism are you using to get continuous auto-focusing? I have tried two.

with a while loop. inside of it, I do the autoFocus method.

This is done in a background thread.

I can get it down to about 1 second or a little less, but there's still that "off" period that makes it a strobe light.

Also, if I don't show the Preview on the screen, the flash doesn't come on. Don't know how to get around that.
 
Upvote 0
autoFocus is only valid after startPreview() has been called. However, I have found that you can call stopPreview() immediately after startPreview(). You never see the preview and the flash still works. :)

awesome...so that part is fixed now. so I guess we are at the same point. Figuring out the "off" period between the flashes.
 
Upvote 0
I had it there, but the "off" period was still pretty long. I was able to get the "off" period to be shorter with the background thread.

hum... so how often are you calling autofocus in your background thread? infinite loop or a timer? I was running a timer before and was getting more off period. I believe the timer's run method is executed in its own thread.
 
Upvote 0
hum... so how often are you calling autofocus in your background thread? infinite loop or a timer? I was running a timer before and was getting more off period. I believe the timer's run method is executed in its own thread.

infinite until a button is clicked. the while loop checks a public variable for the class. if that variable is true, it continues to call the autoFocus(). so when the button is clicked, I just set that value to false, and it stops.
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones