I want to turn on front flash light (not with camera preview) programmatically in Android. I googled for it but the help i found referred me to this page
Does anyone have any links or sample code?
I want to turn on front flash light (not with camera preview) programmatically in Android. I googled for it but the help i found referred me to this page
Does anyone have any links or sample code?
When I updated my SDK version the camera flash quit working with a null pointer exception. I found that I had to set the targetSDKVersion to 22 in the build.gradle When I tried 23 the app crashed.
In Marshmallow and above, CameraManager's `setTorchMode()' seems to be the answer. This works for me:
In API 23 or Higher (Android M, 6.0)
ADDITIONAL EDIT
People still upvoting my answer so I decided to post additional code This was my solution for the problem back in the day:
Complete Code for android Flashlight App
Manifest
XML
MainActivity.java
I have implemented this function in my application through fragments using SurfaceView. The link to this stackoverflow question and its answer can be found here
Hope this helps :)