當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。