Android Camera Server Died and Camera Error - 100

前端 未结 4 809
小鲜肉
小鲜肉 2020-12-09 10:40

I\'m facing Camera error 100 while testing my android application, I have found some topics on StackOverflow but they were not so helpful. I\'m searching for a

4条回答
  •  猫巷女王i
    2020-12-09 11:15

    This exception will occur when the camera parameters have not been set prior to use.

    Here is a method to set the most common default values. Note that this method uses defaults on the assumption that the camera is being used for still photography. Remove the supported picture formats for video capture.

    /**
     * This method configures the camera with a set of defaults for brightness,
     * flash, camera mode, and picture sizes.
     */
    private void setCameraDefaults()
    {
        Camera.Parameters params = mCamera.getParameters();
    
        // Supported picture formats (all devices should support JPEG).
        List formats = params.getSupportedPictureFormats();
    
        if (formats.contains(ImageFormat.JPEG))
        {
            params.setPictureFormat(ImageFormat.JPEG);
            params.setJpegQuality(100);
        }
        else
            params.setPictureFormat(PixelFormat.RGB_565);
    
        // Now the supported picture sizes.
        List sizes = params.getSupportedPictureSizes();
        Camera.Size size = sizes.get(sizes.size()-1);
        params.setPictureSize(size.width, size.height);
    
        // Set the brightness to auto.
        params.setWhiteBalance(Camera.Parameters.WHITE_BALANCE_AUTO);
    
        // Set the flash mode to auto.
        params.setFlashMode(Camera.Parameters.FLASH_MODE_AUTO);
    
        // Set the scene mode to auto.
        params.setSceneMode(Camera.Parameters.SCENE_MODE_AUTO);
    
        // Lastly set the focus to auto.
        params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO);
    
        mCamera.setParameters(params);
    }
    

提交回复
热议问题