Android,打开手电筒

时间:2014-01-07 17:25:12

标签: java android camera

为了打开相机的手电筒,我编写了一些东西。它适用于大多数设备,但有些设备没有,例如LG P970,它不起作用。

在LogCat中,我看到:

01-07 18:20:00.148    1272-2051/? E/CameraHal﹕ Prashanth initDefaultParameters 0
01-07 18:20:00.148    1272-2051/? E/CameraHal﹕ Invalid OLD Video Input  -1. Assume primary camera for capture (default)
01-07 18:20:00.156    1272-2051/? E/CameraHal﹕ setParameters: Invalid panorama mode -1
01-07 18:20:00.156   1272-21021/? E/Arc﹕ setParameters: Invalid panorama value: "-1"
01-07 18:20:00.179  18990-18990/? E/AF_SHR﹕ 18990:affw_eeprom_apply: AFFW : Error reading lens EEPROM
01-07 18:20:00.195    1272-2051/? E/ICapture﹕ 1272:haip_ipipe_find_id: Invalid file descriptor -1
01-07 18:20:00.210    1272-2051/? E/CrayonMediaType﹕ bChkMediaType Can't support [3] Media!!
01-07 18:20:00.210   1272-21031/? E/MPEG4Extractor﹕ both mdat,ftyp not found
01-07 18:20:00.218    1272-2051/? E/CrayonMediaType﹕ bChkMediaType Can't support [3] Media!!
01-07 18:20:00.218   1272-21032/? E/MPEG4Extractor﹕ both mdat,ftyp not found
01-07 18:20:00.250    1272-1340/? E/CameraHal﹕ setParameters: Invalid panorama mode -1
01-07 18:20:00.250   1272-21021/? E/Arc﹕ setParameters: Invalid panorama value: "-1"
01-07 18:20:00.250    1272-2050/? E/CameraHal﹕ Trying to set overlay, but overlay is null!, line:4858

什么是全景模式?如何在 Camera.Parameters 上设置此值?当我调用 setParameters()时会出现这些错误。

开启主要代码:

    private void turnOnFlashLight() {
    Camera.Parameters p = mCamera.getParameters();
    List<String> flashModes = p.getSupportedFlashModes();
    // Check if camera flash exists.
    if (flashModes == null) {
        /*
         * See TroubleShootingActivity, HardwareTestActivity that handle
         * this.
         */
        BusProvider.getBus().post(new HardwareSupportErrorEvent(TestItemType.Flashlight));
    } else {
        String flashMode = p.getFlashMode();
        if (!Camera.Parameters.FLASH_MODE_TORCH.equals(flashMode)) {
            // Turn on the flashlight.
            if (flashModes.contains(Camera.Parameters.FLASH_MODE_TORCH)) {
                p.setFlashMode(Camera.Parameters.FLASH_MODE_TORCH);
                mCamera.setParameters(p);
            }
        }
        startPreview();
    }
}

谢谢

0 个答案:

没有答案