本文整理汇总了Java中android.hardware.Camera.Parameters.FLASH_MODE_TORCH属性的典型用法代码示例。如果您正苦于以下问题:Java Parameters.FLASH_MODE_TORCH属性的具体用法?Java Parameters.FLASH_MODE_TORCH怎么用?Java Parameters.FLASH_MODE_TORCH使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.Camera.Parameters
的用法示例。
在下文中一共展示了Parameters.FLASH_MODE_TORCH属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toggleFlash
private void toggleFlash() {
if (ActivityCompat.checkSelfPermission(this, permission.CAMERA)
!= PackageManager.PERMISSION_GRANTED) {
// this is really unlikely, but I suppose it's possible.
return;
}
// we have to use the Camera.Parameters strings, and this will
// never come back null given how we set it up
@SuppressWarnings({"ConstantConditions", "deprecation"})
boolean isFlashOn = mCameraSource.getFlashMode().equals(Parameters.FLASH_MODE_TORCH);
Drawable iconDrawable = getResources().getDrawable(R.drawable.ic_flashlight_white_24dp);
String newFlashMode = Parameters.FLASH_MODE_TORCH;
if (isFlashOn) {
iconDrawable = getResources().getDrawable(R.drawable.ic_flashlight_off_white_24dp);
newFlashMode = Camera.Parameters.FLASH_MODE_OFF;
}
mCameraSource.setFlashMode(newFlashMode);
torchFab.setImageDrawable(iconDrawable);
}
示例2: toggleFlashMode
/**
* Toggle the flash mode between TORCH and OFF.
* This will take effect immediately or as soon
* as the camera preview becomes active.
* <p/>
* Called from UI thread
*/
public void toggleFlashMode() {
String otherFlashMode = "";
if (mCurrentFlash.equals(Parameters.FLASH_MODE_TORCH)) {
otherFlashMode = Parameters.FLASH_MODE_OFF;
} else {
otherFlashMode = Parameters.FLASH_MODE_TORCH;
}
requestFlash(otherFlashMode);
}