RuntimeException:setParameters在某些redmi设备上失败

时间:2018-04-03 14:29:30

标签: android android-camera android-camera-intent android-camera2

camera = openCamera();
camera.setDisplayOrientation(90);
cameraInfo = new Camera.CameraInfo();
Camera.getCameraInfo(Camera.CameraInfo.CAMERA_FACING_BACK, cameraInfo);
mParameters = camera.getParameters();
mParameters.setRotation(90);
mParameters.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
mParameters.setPictureFormat(PixelFormat.JPEG);
mParameters.setJpegQuality(85);
List<Camera.Size> cameraSize = mParameters.getSupportedPictureSizes();
mPreviewSize = cameraSize.get(0);// get top size
for (int i = 0; i < cameraSize.size(); i++) {
    if (cameraSize.get(i).width > mPreviewSize.width) {
        mPreviewSize = cameraSize.get(i);
    }
}
//set max Picture Size
mParameters.setPictureSize(mPreviewSize.width, mPreviewSize.height);
camera.setParameters(mParameters); // line 46
  

低于异常 java.lang.RuntimeException:setParameters失败                                                                                 在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3190)                                                                                 在   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3300)                                                                                 在android.app.ActivityThread.access $ 1000(ActivityThread.java:211)                                                                                 在   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1705)                                                                                 在android.os.Handler.dispatchMessage(Handler.java:102)                                                                                 在android.os.Looper.loop(Looper.java:145)                                                                                 在android.app.ActivityThread.main(ActivityThread.java:6946)                                                                                 at java.lang.reflect.Method.invoke(Native Method)                                                                                 在java.lang.reflect.Method.invoke(Method.java:372)                                                                                 在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1404)                                                                                 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)                                                                              引起:java.lang.RuntimeException:setParameters失败                                                                                 在android.hardware.Camera.native_setParameters(Native方法)                                                                                 在android.hardware.Camera.setParameters(Camera.java:1964)                                                                                 在   com.tmw.mobilewallet.corporateportal.utils.Preview。(Preview.java:46)

0 个答案:

没有答案