问题
My app turn on camera LED using FLASH_MODE_TORCH
, but now some people say that FLASH_MODE_TORCH
will not work on some Samsung devices correctly.
So should I use FLASH_MODE_ON
for all devices to work?(especially for Samsung devices)
回答1:
may be this will help you
Parameters params = null;
if(mCamera != null) {
params = mCamera.getParameters();
if(params != null) {
List<String> supportedFlashModes = params.getSupportedFlashModes();
if(supportedFlashModes != null) {
if(supportedFlashModes.contains(Parameters.FLASH_MODE_TORCH)) {
params.setFlashMode( Parameters.FLASH_MODE_TORCH );
} else if(supportedFlashModes.contains(Parameters.FLASH_MODE_ON)) {
params.setFlashMode( Parameters.FLASH_MODE_ON );
} else mCamera = null;
} else Log.d(TAG, "Camera is null.");
if(mCamera != null) {
Log.d(TAG, "Flash disponibile (" + params.getFlashMode() + ")");
mCamera.setParameters( params );
mCamera.startPreview();
mCamera.autoFocus(null);
} else Log.d(TAG, "Camera is null.");
回答2:
There is no single way to make sure the flash works on every device. You have to add a lot of code that is specific of the manufacturer and the device.
Dwhanik's answer is how I would handle the specific problem you are talking about. Check for FLASH_MODE_TORCH
first and then try FLASH_MODE_ON
. But this does not mean that you will get a flash on every device.
来源:https://stackoverflow.com/questions/23336907/what-is-the-difference-between-flash-mode-torch-and-flash-mode-on