本文整理匯總了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);
}