经过30行动的Android 3.0拖欧米茄下降抛出:IllegalArgumentException
我的工作与Android 3.0拖欧米茄下降框架。一切工作正常。但经过30行动应用程序会导致IllegalArgumentException异常。
I'm working with android 3.0 drag-n-drop framework. All works fine. But after 30 actions application causes IllegalArgumentException.
09-12 11:17:32.282: WARN/Surface(31132): Not initializing the shared buffer client because token = -12
09-12 11:17:32.282: ERROR/View(31132): Unable to initiate drag
09-12 11:17:32.282: ERROR/View(31132): java.lang.IllegalArgumentException
09-12 11:17:32.282: ERROR/View(31132): at android.view.Surface.lockCanvasNative(Native Method)
09-12 11:17:32.282: ERROR/View(31132): at android.view.Surface.lockCanvas(Surface.java:350)
09-12 11:17:32.282: ERROR/View(31132): at android.view.View.startDrag(View.java:11467)
09-12 11:17:32.282: ERROR/View(31132): at com.example.drag.drop.Dot$1.onTouch(Dot.java:70)
09-12 11:17:32.282: ERROR/View(31132): at android.view.View.dispatchTouchEvent(View.java:4605)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1560)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1291)
09-12 11:17:32.282: ERROR/View(31132): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1709)
09-12 11:17:32.282: ERROR/View(31132): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1264)
09-12 11:17:32.282: ERROR/View(31132): at android.app.Activity.dispatchTouchEvent(Activity.java:2315)
09-12 11:17:32.282: ERROR/View(31132): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1682)
09-12 11:17:32.282: ERROR/View(31132): at android.view.View.dispatchPointerEvent(View.java:4677)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2392)
09-12 11:17:32.282: ERROR/View(31132): at android.view.ViewRoot.handleMessage(ViewRoot.java:2054)
09-12 11:17:32.282: ERROR/View(31132): at android.os.Handler.dispatchMessage(Handler.java:99)
09-12 11:17:32.282: ERROR/View(31132): at android.os.Looper.loop(Looper.java:132)
09-12 11:17:32.282: ERROR/View(31132): at android.app.ActivityThread.main(ActivityThread.java:4123)
09-12 11:17:32.282: ERROR/View(31132): at java.lang.reflect.Method.invokeNative(Native Method)
09-12 11:17:32.282: ERROR/View(31132): at java.lang.reflect.Method.invoke(Method.java:491)
09-12 11:17:32.282: ERROR/View(31132): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
09-12 11:17:32.282: ERROR/View(31132): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
09-12 11:17:32.282: ERROR/View(31132): at dalvik.system.NativeStart.main(Native Method)
09-12 11:17:34.272: WARN/WindowManager(4050): Drag already in progress
09-12 11:17:34.622: WARN/WindowManager(4050): Drag already in progress
09-12 11:17:34.912: WARN/WindowManager(4050): Drag already in progress
09-12 11:17:35.462: WARN/WindowManager(4050): Drag already in progress
09-12 11:17:35.782: WARN/WindowManager(4050): Drag already in progress
09-12 11:17:37.282: ERROR/WindowManager(4050): Unregister of nonexistent drag input channel
应用dalvinkvm呼吁各的dragEvent后重新正常工作
Application again works fine after dalvinkvm calls for each DragEvent
09-12 11:18:06.662: WARN/Surface(31132): Surface.finalize() has work. You should have called release() (1720472, 0)
正如你所看到的异常和定稿之间的延迟时间大约为30秒。
As you can see time delay between exception and finalization is approximately 30 sec.
同样的异常两个示例项目时从书本:
Same exception occurs on two example projects from books:
1)http://www.manning.com/collins/;例如在第15章: HTTP://www.manning-sandbox。 COM / thread.jspa邮件ID = 117809&放大器; TSTART = 0
1)http://www.manning.com/collins/; example on chapter 15: http://www.manning-sandbox.com/thread.jspa?messageID=117809&tstart=0
2)的http://www.a$p$pss.com/9781430232223;例如在第31章
2)http://www.apress.com/9781430232223; example on chapter 31
问:
1)如何正确地完成DragEvents?
1)How finalize DragEvents properly?
或
2)如何调用Surface.finalize()如果我正在使用的GridView的例子吗?
2)How call Surface.finalize() if I'm working with GridView for example?
感谢。
我一直在努力奋斗着这个蜂窝错误的天,找到了出路吧,虽然我不知道你的情况是类似我的。
就我而言,现在我可以肯定地说,无法启动阻力的消息是在一个连锁反应开始,到数据适配器进行的更新支持一个ListView(其中的项目,我试图让用户的结束拖放)。问题是,事实上,随着水滴,在那里我会改变一些基础数据并要求适配器通知DataSetChanged的ListView控件。
没有什么神奇的对我来说,相当令人惊讶的,是取代每次调用:
I've been struggling with this Honeycomb bug for days, and found a way out of it, although I'm not sure your situation is similar to mine.
In my case, now I can say for certain, the "Unable to initiate drag" message was at the end of a chain-reaction starting with updates made to a data-adapter supporting a ListView (whose items I was trying to allow the user drag and drop). The problem was, in fact, with the "Drop", where I would change something in the underlying data and ask the adapter to notify the ListView of DataSetChanged.
What did the magic for me, quite amazingly, was replacing every call to:
lv.getAdapter().notifyDataSetChanged();
有:
with:
resetListView(lv)
定义为:
private void resetListView(ListView lv)
{
int position = lv.getFirstVisiblePosition();
int y = lv.getChildAt(0).getTop();
lv.setAdapter(lv.getAdapter());
lv.setSelectionFromTop(position, y);
}
类似notifyDataSetChanged(),这个方法可以确保ListView控件得到了最新的适配器,数据更新,但除此之外,它也将重置ListView控件,preventing后来拖 - 放里面的一些内部结构链反应,导致上述的异常。
生活与蜂窝是不容易的。
Similar to notifyDataSetChanged(), this method makes sure that the ListView gets updated with the latest adapter-data, but in addition, it also resets some internal structures inside the ListView, preventing the later drag-and-drop chain-reaction leading to the above mentioned exception.
Life with Honeycomb is NOT easy.