调用Android手机自带的闪光灯

关键代码:

@Override
	protected void onNewIntent(Intent intent) {
		Logger.i("onNewIntent");
		super.onNewIntent(intent);
		if (opened) {
			// 关闭
			// parameters = mCamera.getParameters();
			parameters.setFlashMode(Parameters.FLASH_MODE_OFF);
			mCamera.setParameters(parameters);
			// mCamera.stopPreview();
			mCamera.release();
			mCamera = null;
		} else {
			// 开启
			mCamera = Camera.open();
			// mCamera.setPreviewDisplay(null);
			parameters = mCamera.getParameters();
			parameters.setFlashMode(Parameters.FLASH_MODE_TORCH);
			mCamera.setParameters(parameters);
			// mCamera.startPreview();
		}
		opened = !opened;
	}

<activity
            android:launchMode="singleInstance"
            android:theme="@android:style/Theme.NoDisplay"


你可能感兴趣的:(调用Android手机自带的闪光灯)