当前位置: 首页>>代码示例>>Java>>正文


Java Parameters.getFlashMode方法代码示例

本文整理汇总了Java中android.hardware.Camera.Parameters.getFlashMode方法的典型用法代码示例。如果您正苦于以下问题:Java Parameters.getFlashMode方法的具体用法?Java Parameters.getFlashMode怎么用?Java Parameters.getFlashMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.hardware.Camera.Parameters的用法示例。


在下文中一共展示了Parameters.getFlashMode方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: turnLightOff

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * 通过设置Camera关闭闪光灯
 * 
 * @param mCamera
 */
public void turnLightOff() {
	if (camera == null) {
		return;
	}
	Parameters parameters = camera.getParameters();
	if (parameters == null) {
		return;
	}
	List<String> flashModes = parameters.getSupportedFlashModes();
	String flashMode = parameters.getFlashMode();
	// Check if camera flash exists
	if (flashModes == null) {
		return;
	}
	// 闪光灯打开状态
	if (!Parameters.FLASH_MODE_OFF.equals(flashMode)) {
		// Turn off the flash
		if (flashModes.contains(Parameters.FLASH_MODE_OFF)) {
			parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
			camera.setParameters(parameters);
		} else {
			Log.e(TAG, "FLASH_MODE_OFF not supported");
		}
	}
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:31,代码来源:CameraManager.java

示例2: setFlashState

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/** Turns the LED on or off if phone has one. */
public synchronized void setFlashState(boolean state) {
	Log.d("flash", "flash called");
	// If the camera has already been opened, we apply the change immediately
	if (mCamera != null) {
		Log.d("flash", "camera not null");
		if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
			lockCamera();
		}
		Parameters parameters = mCamera.getParameters();

		// We test if the phone has a flash
		if (parameters.getFlashMode()==null) {
			// The phone has no flash or the choosen camera can not toggle the flash
			throw new RuntimeException("Can't turn the flash on !");
		} else {
			parameters.setFlashMode(state?Parameters.FLASH_MODE_TORCH:Parameters.FLASH_MODE_OFF);
			try {
				mCamera.setParameters(parameters);
				mFlashEnabled = state;
			} catch (RuntimeException e) {
				mFlashEnabled = false;
				throw new RuntimeException("Can't turn the flash on !");
			} finally {
				if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
					unlockCamera();
				}
			}
		}
	} else {
		mFlashEnabled = state;
	}
}
 
开发者ID:galme,项目名称:ROLF-EV3,代码行数:34,代码来源:VideoStream.java

示例3: turnLightOn

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static void turnLightOn(Camera mCamera) {  
    if (mCamera == null) {  
        return;  
    }  
    Parameters parameters = mCamera.getParameters();  
    if (parameters == null) {  
        return;  
    }  
List<String> flashModes = parameters.getSupportedFlashModes();  
    // Check if camera flash exists  
    if (flashModes == null) {  
        // Use the screen as a flashlight (next best thing)  
        return;  
    }  
    String flashMode = parameters.getFlashMode();  
    Log.i(TAG, "Flash mode: " + flashMode);  
    Log.i(TAG, "Flash modes: " + flashModes);  
    if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {  
        // Turn on the flash  
        if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {  
            parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);  
            mCamera.setParameters(parameters);  
        } else {  
        }  
    }  
}
 
开发者ID:li-yu,项目名称:iTester,代码行数:27,代码来源:FlashlightManager.java

示例4: turnLightOn

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/**
 * 通过设置Camera打开闪光灯
 */
public void turnLightOn() {
	if (camera == null) {
		return;
	}
	Parameters parameters = camera.getParameters();
	if (parameters == null) {
		return;
	}

	List<String> flashModes = parameters.getSupportedFlashModes();
	if (flashModes == null) {
		return;
	}
	String flashMode = parameters.getFlashMode();
	Log.i(TAG, "Flash mode: " + flashMode);
	Log.i(TAG, "Flash modes: " + flashModes);
	// 闪光灯关闭状态
	if (!Parameters.FLASH_MODE_TORCH.equals(flashMode)) {
		// Turn on the flash
		if (flashModes.contains(Parameters.FLASH_MODE_TORCH)) {
			parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
			camera.setParameters(parameters);
			camera.startPreview();
		} else {
		}
	}
}
 
开发者ID:guzhigang001,项目名称:Zxing,代码行数:31,代码来源:CameraManager.java

示例5: isFlashSupported

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
public static boolean isFlashSupported(Camera camera) {
    if (camera == null) {
        return false;
    }
    Parameters parameters = camera.getParameters();
    if (parameters.getFlashMode() == null) {
        return false;
    }
    List<String> supportedFlashModes = parameters.getSupportedFlashModes();
    if (supportedFlashModes == null || supportedFlashModes.isEmpty() || (supportedFlashModes.size() == 1 && ((String) supportedFlashModes.get(0)).equals("off"))) {
        return false;
    }
    return true;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:15,代码来源:CameraUtils.java

示例6: setFlashState

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/** Turns the LED on or off if phone has one. */
public synchronized void setFlashState(boolean state) {
	// If the camera has already been opened, we apply the change immediately
	if (mCamera != null) {

		if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
			lockCamera();
		}

		Parameters parameters = mCamera.getParameters();

		// We test if the phone has a flash
		if (parameters.getFlashMode()==null) {
			// The phone has no flash or the choosen camera can not toggle the flash
			throw new RuntimeException("Can't turn the flash on !");
		} else {
			parameters.setFlashMode(state?Parameters.FLASH_MODE_TORCH:Parameters.FLASH_MODE_OFF);
			try {
				mCamera.setParameters(parameters);
				mFlashEnabled = state;
			} catch (RuntimeException e) {
				mFlashEnabled = false;
				throw new RuntimeException("Can't turn the flash on !");
			} finally {
				if (mStreaming && mMode == MODE_MEDIARECORDER_API) {
					unlockCamera();
				}
			}
		}
	} else {
		mFlashEnabled = state;
	}
}
 
开发者ID:ghazi94,项目名称:Android_CCTV,代码行数:34,代码来源:VideoStream.java

示例7: turnLightOff

import android.hardware.Camera.Parameters; //导入方法依赖的package包/类
/** 
 * ͨ������Camera�ر������ 
 * @param mCamera 
 */  
public static void turnLightOff(Camera mCamera) {  
    if (mCamera == null) {  
        return;  
    }  
    Parameters parameters = mCamera.getParameters();  
    if (parameters == null) {  
        return;  
    }  
    List<String> flashModes = parameters.getSupportedFlashModes();  
    String flashMode = parameters.getFlashMode();  
    // Check if camera flash exists  
    if (flashModes == null) {  
        return;  
    }  
    Log.i(TAG, "Flash mode: " + flashMode);  
    Log.i(TAG, "Flash modes: " + flashModes);  
    if (!Parameters.FLASH_MODE_OFF.equals(flashMode)) {  
        // Turn off the flash  
        if (flashModes.contains(Parameters.FLASH_MODE_OFF)) {  
            parameters.setFlashMode(Parameters.FLASH_MODE_OFF);  
            mCamera.setParameters(parameters);  
        } else {  
            Log.e(TAG, "FLASH_MODE_OFF not supported");  
        }  
    }  
}
 
开发者ID:li-yu,项目名称:iTester,代码行数:31,代码来源:FlashlightManager.java


注:本文中的android.hardware.Camera.Parameters.getFlashMode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。