Android后置摄像头拍摄照片无需预览

时间:2013-07-23 21:42:52

标签: java android android-camera android-4.2-jelly-bean samsung-mobile

我已经在Tutorial Link

跟踪 Lars Vogel 的教程

虽然本教程适用于前置摄像头,但遗憾的是无法让后置摄像头拍照。它迟到了,我可能会错过一些简单的东西。我的代码是:

private int findBackFacingCamera() {
    int cameraId = 0;
    // Search for the back facing camera
    int numberOfCameras = Camera.getNumberOfCameras();
    for (int i = 0; i < numberOfCameras; i++) {
        CameraInfo info = new CameraInfo();
        Camera.getCameraInfo(i, info);
        if (info.facing == CameraInfo.CAMERA_FACING_BACK) {
            Log.d(DEBUG_TAG, "Camera found"  + info.facing);
            cameraId = i;
            break;
        }
    }
    return cameraId;
}

1 个答案:

答案 0 :(得分:0)

确保您拥有Android清单中列出的后置摄像头的正确权限。

另外,请查看此问题:How do I open the "front camera" on the Android platform?