Originally Posted by a-ssassi-n
I need help with coding.
i created a flashlight application by using camera API getCamera()
it works but when the screen goes off or i minimize the application the led light turns off.
looking forward for your reply.
thanks in advance.
and BTW nice work with your app.
The LED is tricky, lots of devices have a lot of different quirks with them so make sure your issues are not devices specific. When I was programming the LED stuff awhile ago I remember having the opposite problem.
I don't know about getCamera() and don't see anything about it in the docs. I use camera = Camera.open() (the rear camera is the default). I have to release the camera (camera.release()) on pause or else it caused problems with the stock camera app. To turn the light on I set the flash mode, parameters and then startPreview. I found this to work on the most devices. Some devices like autoFocus to be set also but a greater amount hate it.
Also remember that you have to give your users a way to turn it off when the app is not opened. I would recommend a notification. If they have to reopen your app through multitasking to turn it off that's a "fail, one star, uninstall" type of a thing.