我正在尝试创建一个使用相机的应用,并尝试在用户触摸相机预览时启用自动对焦。
我使用此方法启用onTouch焦点。
params.setFocusAreas(focusAreas);
它适用于大多数三星设备。
但是当我在任何华为手机上测试时,它都无法正常工作并崩溃。
好消息是,如果我不使用,它在华为上效果很好:
Huawei Honor 5X (HNKIW-Q), 2048MB RAM, Android 6.0
java.lang.RuntimeException:
at android.hardware.Camera.native_setParameters (Native Method)
at android.hardware.Camera.setParameters (Camera.java:2260)
at MY_PACKAGE_NAME.ReadingActivity.cameraFocus (ReadingActivity.java:329)
at MY_PACKAGE_NAME.ReadingActivity.access$800 (ReadingActivity.java:32)
at MY_PACKAGE_NAME.ReadingActivity$3.onTouch (ReadingActivity.java:281)
at android.view.View.dispatchTouchEvent (View.java:9384)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2197)
at android.view.ViewGroup.dispatchTransformedTouchEvent (ViewGroup.java:2555)
at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:2197)
at com.android.internal.policy.PhoneWindow$DecorView.superDispatchTouchEvent (PhoneWindow.java:2461)
at com.android.internal.policy.PhoneWindow.superDispatchTouchEvent (PhoneWindow.java:1777)
at android.app.Activity.dispatchTouchEvent (Activity.java:2865)
at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent (WindowCallbackWrapper.java:68)
at com.android.internal.policy.PhoneWindow$DecorView.dispatchTouchEvent (PhoneWindow.java:2422)
at android.view.View.dispatchPointerEvent (View.java:9610)
at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent (ViewRootImpl.java:4447)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess (ViewRootImpl.java:4313)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3847)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3900)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3866)
at android.view.ViewRootImpl$AsyncInputStage.forward (ViewRootImpl.java:3992)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3874)
at android.view.ViewRootImpl$AsyncInputStage.apply (ViewRootImpl.java:4049)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3847)
at android.view.ViewRootImpl$InputStage.onDeliverToNext (ViewRootImpl.java:3900)
at android.view.ViewRootImpl$InputStage.forward (ViewRootImpl.java:3866)
at android.view.ViewRootImpl$InputStage.apply (ViewRootImpl.java:3874)
at android.view.ViewRootImpl$InputStage.deliver (ViewRootImpl.java:3847)
at android.view.ViewRootImpl.deliverInputEvent (ViewRootImpl.java:6146)
at android.view.ViewRootImpl.doProcessInputEvents (ViewRootImpl.java:6120)
at android.view.ViewRootImpl.enqueueInputEvent (ViewRootImpl.java:6081)
at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent (ViewRootImpl.java:6262)
at android.view.InputEventReceiver.dispatchInputEvent (InputEventReceiver.java:192)
at android.os.MessageQueue.nativePollOnce (Native Method)
at android.os.MessageQueue.next (MessageQueue.java:330)
at android.os.Looper.loop (Looper.java:137)
at android.app.ActivityThread.main (ActivityThread.java:5621)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:684)
这是错误日志:
{{1}}
我想弄清楚为什么会出现这种情况并修复它?