I have developed a code to open the flashlight in android phones with torch mode. I don't know if torch mode is not supported in Motorola razor but it does works on Motorola g. My question actually is..
1) If you could provide me a way so i could read and according to what a phone supports change my code for them to open flash
2)How should i change my code so it'll be supported by the razor.
private void turnOnFlash() {
if (!isFlashOn) {
if (camera == null || params == null) {
return;
}
// play sound
// playSound();
try {
params = camera.getParameters();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.startPreview();
isFlashOn = true;
}catch (RuntimeException e) {
}
}
}
Should i add something like that?
List<String> flashModes = params.getSupportedFlashModes();
if (flashModes.contains(android.hardware.Camera.Parameters.FLASH_MODE_AUTO))
{
params.setFlashMode(Parameters.FLASH_MODE_AUTO);
}