单实例活动不接收输入事件
我的应用程序中有 2 个单实例活动,一个是登录活动 (A),它也是启动屏幕,另一个是应用程序主活动 (B)。如果我在 B 上,按手机上的主页键并转到手机上的主屏幕,那么过了一会儿,如果我转到 应用领域-->然后按我的应用程序图标 -->我回到 B。但有时 B 没有反应。如果我查看日志,我会发现触摸事件将发送到 A,但会显示 B。这是安卓的一个bug吗?看起来android认为自从应用程序启动后就显示了A,但实际上显示了B。有没有人遇到类似的问题
I have 2 single instance activities in my app one is Log in Activity(A) which is also startup screen and other is kind of application home Activity(B). If I am on B and press home key on phone and go to home screen on phone then after a while if I go to
Applications --> and Press my application icon --> I come back to B. But sometimes B is non responsive. If I look at logs I see touch events are going to A but B is displayed. Is that a bug in Android. It looks like android thinks since app is launched A is displayed but actually B is displayed. Has anyone faced similar issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,当您单击主屏幕时,应用程序(活动)将进入“暂停”状态并最小化。当您再次单击时,应用程序系统将调用“onResume”并恢复应用程序的最后一个状态,即您的情况下的状态 B。(我假设屏幕 A 和 B 是两个活动)。但是,如果您想返回应用程序的主屏幕,您应该单击后退按钮而不是主屏幕。
但是,如果您使用两个视图,则很可能会出现您所描述的问题(它们实际上不是问题或错误)。捕捉触摸或运动事件时需要小心。
As far as i know when you click home screen the application (Activity) goes into a "Pause" state and minimizes. When you click again the application system will call "onResume" and resume the last state of the application which is state B in your case.(I assume screen A and B are two activities). But if you want to get back to home screen of your app you should click back button not the home screen.
But if you are using two views its very possible to have problems as you are describing ( they are really not the problems or bugs). You need to be careful when you are catching the touch or motion events.