相机闪光灯未关闭

时间:2016-07-20 17:07:29

标签: android android-camera

所以我正在开展一项活动,您应该拍摄照片,然后将其上传到Parse服务器。

除闪光模式外,一切正常;打开它工作但关闭它不起作用。

这是我打开闪光灯的代码:

private void turnOnFlash() {
    Camera.Parameters params = camera.getParameters();
    if (!isFlashOn) {
        if (camera == null || params == null) {
            return;
        }
        params.setFlashMode(Camera.Parameters.FLASH_MODE_ON);
        camera.setParameters(params);
        isFlashOn = true;

        // Show the flash mode in a Toast.
        Toast.makeText(this, "Flash mode: " + camera.getParameters().getFlashMode(), Toast.LENGTH_SHORT).show();

        // Changing button image.
        imgFlash.setImageResource(R.drawable.ic_flash_on_white_48dp);
    }
}

这是关闭闪光灯的代码:

private void turnOffFlash() {
    Camera.Parameters params = camera.getParameters();
    if (isFlashOn) {
        if (camera == null || params == null) {
            return;
        }
        params.setFlashMode(Camera.Parameters.FLASH_MODE_OFF);
        camera.setParameters(params);
        isFlashOn = false;

        // Show the flash mode in a Toast.
        Toast.makeText(this, "Flash mode: " + camera.getParameters().getFlashMode(), Toast.LENGTH_SHORT).show();

        // Changing button image.
        imgFlash.setImageResource(R.drawable.ic_flash_off_white_48dp);
    }
}

任何帮助都将不胜感激。

修改

显示闪光模式的Toast在调用Flash mode: off方法时显示turnOffFlash(),但闪光灯仍然显示。

0 个答案:

没有答案