what is the difference between FLASH_MODE_TORCH AND FLASH_MODE_ON

假装没事ソ 提交于 2019-12-19 04:08:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!