Access denied finding property “camera.hal1.packagelist”

后端 未结 5 1168
别那么骄傲
别那么骄傲 2021-02-05 03:07

While using camera in service mobile screen is getting un-touchable(locked by transparent window ) and only below error is occuring

Access denied finding proper         


        
5条回答
  •  余生分开走
    2021-02-05 03:38

    I had the same problem with the Camera 1 API on my Test device "LG V30". I found out, that this message (Access denied finding property "camera.hal1.packagelist") appeared when I opened the camera like this:

    int numberOfCameras = Camera.getNumberOfCameras();
    CameraInfo cameraInfo = new CameraInfo();
    for (int i = 0; i < numberOfCameras; i++) {
        Camera.getCameraInfo(i, cameraInfo);
        if (cameraInfo.facing == CameraInfo.CAMERA_FACING_BACK) {
            camera = Camera.open(i);
            cameraId = i;
        }
    }
    

    Important is, that this only happened for the LG V30, which has 2 back cameras (numberOfCameras=3).

    After some testing I found out, that this works for this device:

    /** A safe way to get an instance of the Camera object. */
    public static Camera getCameraInstance(){
        Camera c = null;
        try {
            c = Camera.open(); // attempt to get a Camera instance
        }
        catch (Exception e){
            // Camera is not available (in use or does not exist)
        }
        return c; // returns null if camera is unavailable
    }
    

    The example code above will access the first, back-facing camera on a device with more than one camera. Here you can find a detailed description.

提交回复
热议问题