當前位置: 首頁>>代碼示例>>Java>>正文


Java Parameters.FLASH_MODE_TORCH屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:particle-iot,項目名稱:photon-tinker-android,代碼行數:22,代碼來源:BarcodeScannerActivity.java

示例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);
}
 
開發者ID:PerchLive,項目名稱:PerchBroadcast-Android-SDK,代碼行數:16,代碼來源:CameraEncoder.java


注:本文中的android.hardware.Camera.Parameters.FLASH_MODE_TORCH屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。