what is the difference between FLASH_MODE_TORCH AND FLASH_MODE_ON

不羁岁月 提交于 2019-11-30 23:56:30

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.");

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.

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