surfaceCreated方法报setParameters failed错解决办法

public void surfaceCreated(SurfaceHolder holder){
   
surfaceHolder = holder
        Log.d(TAG, "surfaceCreated" + mCamera);

        try {
            CamcorderProfile profile ;

            int numCameras = Camera.getNumberOfCameras();
            if (numCameras > 1) {
            profile = (CamcorderProfile
                        .get(Camera.CameraInfo.CAMERA_FACING_FRONT,CamcorderProfile.QUALITY_HIGH));
            }
            else{

                profile = (CamcorderProfile
                        .get(Camera.CameraInfo.CAMERA_FACING_BACK,CamcorderProfile.QUALITY_HIGH));
            }

	    //设置camera预览的角度,因为默认图片是倾斜90度的   
	    camera.setDisplayOrientation(90); 
            Camera.Parameters parameters = mCamera.getParameters();
            parameters.setPreviewSize(profile.videoFrameWidth, profile.videoFrameHeight);
            mCamera.setParameters(parameters);
            mCamera.setPreviewDisplay(holder);
            mCamera.startPreview();
        }
        catch (IOException e) {
           
        }}

你可能感兴趣的:(android)