i made Camera Preview using CameraSource in Android Studio
new CameraSource.Builder(this , detector).setAutoFocusEnabled(true).build();
as you can see i easliy set the Auto Focus Enabled.
i was just wondering if there is an easy way to enable/disable flashlight ?
Just use this method:
.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH).build();
Edit:
This class was deprecated in API level 21. Google recommends using the new android.hardware.camera2 API for new applications.
In this thread you can see how to use: Turning on/off flash with Android camera2 API not working
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With