android – Carousel中的ArrayIndexOutOfBoundsException – MessageQueue回调和handleReceiveCallback中的异常

前端之家收集整理的这篇文章主要介绍了android – Carousel中的ArrayIndexOutOfBoundsException – MessageQueue回调和handleReceiveCallback中的异常前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在我的应用程序中使用轮播.

对于拥有Android 4.2.2且仅在横向模式下的用户,他们报告此问题:

12-19 15:01:56.685: E/InputEventReceiver(7009): Exception dispatching input event.
12-19 15:01:56.685: E/MessageQueue-JNI(7009): Exception in MessageQueue callback: handleReceiveCallback
12-19 15:01:56.695: E/MessageQueue-JNI(7009): java.lang.ArrayIndexOutOfBoundsException: length=12; index=-1
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2076)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at com.digitalaria.gama.carousel.CarouselBehavior.dispatchTouchEvent(CarouselBehavior.java:1768)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2401)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2091)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2401)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2091)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2401)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2091)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2401)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2091)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2401)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2091)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2401)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2091)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2284)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1578)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.app.Activity.dispatchTouchEvent(Activity.java:2468)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2232)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.View.dispatchPointerEvent(View.java:7876)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3894)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3778)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5030)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5009)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5107)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.os.MessageQueue.nativePollOnce(Native Method)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.os.MessageQueue.next(MessageQueue.java:125)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.os.Looper.loop(Looper.java:124)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at android.app.ActivityThread.main(ActivityThread.java:5283)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at java.lang.reflect.Method.invokeNative(Native Method)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at java.lang.reflect.Method.invoke(Method.java:511)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
12-19 15:01:56.695: E/MessageQueue-JNI(7009):   at dalvik.system.NativeStart.main(Native Method)

我无法在这里找到问题所在.

解决方法

看起来您将视图存储在数组中.

旋转设备时,将重置此阵列并删除所有视图.当数组适配器尝试获取其位置时,因为该数组为空,所以它返回-1.

尝试处理旋转事件并确保重新填充数组.

我没有看到一些代码就无法回答,但它看起来像是清空或设置为null的视图数组/列表.

猜你在找的Android相关文章