I'm programming on android and I need to access the camera flash on the device. I read that the class Camera android considers it obsolete so try to use the CameraManager class but I have a problem, in the following code
public void flashOn() {
try {
//aca esta el problema ya que la version que estoy trabajando (api 22) es menor que la api que necesita el metodo setTorchMode (api 23)
//entonces el if siempre es false y nunca enciende la camara
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
Toast.makeText(this,"acceso",Toast.LENGTH_LONG).show();
mCameraManager.setTorchMode(mCameraId, true);
rotate();
}
} catch (Exception e) {
e.printStackTrace();
}
}
The question is how do I activate the flash on devices with api less than 23, should I use the Camera class that Android considers obsolete?