当我一直按“返回”键回到第一个菜单后,我有一个深层的子活动被调用(无缘无故)
我有 ListView 的主要活动。
单击列表项可通过按钮启动活动 B。
单击按钮启动带有列表视图的活动 C。
单击列表项可启动具有只读文本视图的活动 D。
到目前为止一切都很好。
我多次单击“返回”以返回到主要活动。
然后,活动 C 的 createBundle 突然被某个类调用 Instrumentation.callActivityOnCreate(Activity,Bundle),这会导致活动 C 出现。
我尝试使用 startActivityForResult 和 onActivityResult 来看看它是否会产生 不同之处。没有。仍然发生。
如果我用一个名为 Z 的简单文本视图活动替换活动 C,也会发生这种情况。 我备份到主要活动后会显示 Z。
有人见过这个吗?
为什么到达最顶层活动时会调用深层子活动(不调用此活动)?
I have Main activity with ListView.
Clicking on a list item starts activity B with a button.
Clicking on a button starts an activity C with a list view.
Clicking on a list item starts activity D with readonly text view.
All good so far.
I click Back many times to get back to the main activity.
Then, out of nowhere, activity C's createBundle is called by some class
Instrumentation.callActivityOnCreate(Activity,Bundle), and this causes activity C to
show up.
I tried using startActivityForResult and onActivityResult to see if it would make a
difference. Nope. Still happens.
I also happens if I subsitite activity C with a simple text view activity called Z.
Z gets shown after I back up to the main activity.
Anyone ever see this?
Why is a deep sub activity being called when the topmost activity is reached (which doesn't call this activity) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我通过到处设置断点来解决这个问题。
我的 Activity B 有一个按钮,用于启动 Activity C。
我在按钮上放置了 OnTouchListener,而不是 ONClickListener。
当我单击按钮时,触摸监听器调用活动 C 。这很好。
但是,从活动 D 开始,如果我多次按 BACK 进入主活动菜单...
有些东西正在向活动 B 的按钮发送触摸事件(即使我在主活动中),这会导致对活动 C 的调用。
对于新手来说,根本无法直观地注意到。
我希望这对某人有帮助。
I figured it out by setting breakpoints everywhere.
My Activity B has a button, which is used to launch activity C.
Instead of an ONClickListener, I put on OnTouchListener on the button.
When I click on the button, the on touch listener invoked activity C . This is fine.
However, from activity D, if I press BACK many times to get to the main activity menu...
something is sending a touch event to the button of activity B (even though I am on the main activity) , and this causes a call to activity C.
Not intuitive to notice at all... for a newbie.
I hope this helps someone.