我知道之前已经问过这个问题,我确实已经阅读了所有的解决方案,但我的情况有点奇怪,我继续在开发者帐户上获得以下崩溃报告:
java.lang.RuntimeException:at android.hardware.Camera.native_setParameters(Native Method:0)at android.hardware.Camera.setParameters(Camera.java:2080)at com.xxxxxxxxxx.core.xxxxxxxx.xxxxxxx.surfaceCreated(BackgroundVideoRecorder.java:119) 在android.view.SurfaceView.updateWindow(SurfaceView.java:675)at android.view.SurfaceView $ 3.onPreDraw(SurfaceView.java:185)at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944) 在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2050) 在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1117)at android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6175) 在 android.view.Choreographer $ CallbackRecord.run(Choreographer.java:773) 在android.view.Choreographer.doCallbacks(Choreographer.java:586)at android.view.Choreographer.doFrame(Choreographer.java:556)at android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:759) 在android.os.Handler.handleCallback(Handler.java:739)处 android.os.Handler.dispatchMessage(Handler.java:95)at android.os.Looper.loop(Looper.java:135)at android.app.ActivityThread.main(ActivityThread.java:5421)at java.lang.reflect.Method.invoke(Native Method:0)at java.lang.reflect.Method.invoke(Method.java:372)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:914) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)
为了广告而删除了应用程序名称,我在多个设备上尝试了应用程序,我无法到达重现错误,即使我尝试过的设备在崩溃报告中可用,也在我的参数生成过程中我确保检查每个参数是否都受支持,通过检查相机参数这里的代码如下:
if (front) {
params = camera.getParameters();
params.setRotation(90);
List<String> focusModes = params.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
Log.w("VideoTakerFront","Continuous Video Supported");
}
} else {
params = camera.getParameters();
params.setRotation(270);
List<String> focusModes = params.getSupportedFocusModes();
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
params.setFocusMode(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
Log.w("VideoTakerBack","Continuous Video Supported");
}
}
camera.setParameters(params);
if (android.os.Build.VERSION.SDK_INT>=android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
camera.enableShutterSound(false);
}
else{
AudioManager audio= (AudioManager)this.getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
audio.setStreamVolume(AudioManager.STREAM_SYSTEM, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);
}
Log.w("VideoTaker", "Open Camera");
感谢您的帮助!
答案 0 :(得分:0)
我发现了问题...报告此问题的用户使用的是旧版本的应用程序,我没注意版本,这个问题曾经发生在旧版本中,之前我没有做过。用于获得支持的对焦模式并检查它是否可用,谢谢!