本文整理匯總了Java中android.hardware.Camera.Parameters.getSupportedFlashModes方法的典型用法代碼示例。如果您正苦於以下問題:Java Parameters.getSupportedFlashModes方法的具體用法?Java Parameters.getSupportedFlashModes怎麽用?Java Parameters.getSupportedFlashModes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.getSupportedFlashModes方法的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");
}
}
}
示例2: hasFlashlight
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
/**
* ͨ������Camera�������
* @param mCamera
*/
public static boolean hasFlashlight(Camera mCamera)
{
if (mCamera == null) {
return false;
}
Parameters parameters = mCamera.getParameters();
if (parameters == null) {
return false;
}
List<String> flashModes = parameters.getSupportedFlashModes();
// Check if camera flash exists
if (flashModes == null) {
// Use the screen as a flashlight (next best thing)
return false;
}
else return true;
}
示例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 {
}
}
}
示例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 {
}
}
}
示例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;
}
示例6: 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");
}
}
}
示例7: requestFlash
import android.hardware.Camera.Parameters; //導入方法依賴的package包/類
/**
* Sets the requested flash mode and restarts the
* camera preview. This will take effect immediately
* or as soon as the camera preview becomes active.
* <p/>
* <p/>
* Called from UI thread
*/
public void requestFlash(String desiredFlash) {
mDesiredFlash = desiredFlash;
/* If mCamera for some reason is null now flash mode will be applied
* next time the camera opens through mDesiredFlash. */
if (mCamera == null) {
Log.w(TAG, "Ignoring requestFlash: Camera isn't available now.");
return;
}
Parameters params = mCamera.getParameters();
List<String> flashModes = params.getSupportedFlashModes();
/* If the device doesn't have a camera flash or
* doesn't support our desired flash modes return */
if (VERBOSE) {
Log.i(TAG, "Trying to set flash to: " + mDesiredFlash + " modes available: " + flashModes);
}
if (isValidFlashMode(flashModes, mDesiredFlash) && mDesiredFlash != mCurrentFlash) {
mCurrentFlash = mDesiredFlash;
mDesiredFlash = null;
try {
params.setFlashMode(mCurrentFlash);
mCamera.setParameters(params);
if (VERBOSE) {
Log.i(TAG, "Changed flash successfully!");
}
} catch (RuntimeException e) {
Log.d(TAG, "Unable to set flash" + e);
}
}
}