I am trying to create a flash torch app for my motorola fire xt-530.
check this code which responds to a toggle button.
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (isChecked) {
if (getApplicationContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_CAMERA_FLASH)) {
camera = Camera.open();
params = camera.getParameters();
List<String> flashModes = params.getSupportedFlashModes();
if (flashModes == null) {
Toast.makeText(getApplicationContext(), "No Flash Found",
Toast.LENGTH_SHORT).show();
} else {
camera.startPreview();
if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {
Toast.makeText(getApplicationContext(),
"Torch Mode Found", Toast.LENGTH_SHORT).show();
params.setFlashMode(Parameters.FLASH_MODE_TORCH);
camera.setParameters(params);
camera.takePicture(null, null, null);
} else {
Toast.makeText(getApplicationContext(),
"Torch Mode Not Found", Toast.LENGTH_SHORT).show();
}
}
} else {
Toast.makeText(getApplicationContext(), "Not Available",
Toast.LENGTH_SHORT).show();
}
} else {
camera.stopPreview();
camera.release();
Toast.makeText(getApplicationContext(), "Not Checked",
Toast.LENGTH_SHORT).show();
}
which toasts torch mode not found. not rooted.
please help me.
Not all Android phones support Torch Mode (I believe yours is one of them). However one solution is to root the phone and set custom ROM which supports it. The other is maybe to try to make a workaround with FLASH_MODE_ON or you can even try to trigger FLASH MODE TORCH even if it is not in the list of supported ones.. I had several cases when that worked.