Android 应用程序在终止主要活动时未关闭
我有一个应用程序,它有一个主(根)活动,它是一个启动屏幕,并通过意图启动菜单活动。问题是,当我在菜单中并按后退按钮时,它会按应有的方式返回到我的启动屏幕,但是当我再次按后退按钮退出应用程序时,它会关闭我的启动屏幕活动并返回到菜单活动。此时,我可以第三次按后退按钮,然后似乎完全关闭了应用程序。我相信解决方案可能是使用一些启动模式配置。有什么想法吗?
I have an App that has a Main (root) activity which is a splash screen and launches a menu activity through an intent. The problem is when I am in the menu and press the back button it goes back to my splash screen as it should, but when I press the back button again to exit the app it closes my splash screen activity and goes back to the menu activity. At this point I can press the back button a third time which then appears to fully close the app. I believe the solution may to to use some launch mode configuration. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
启动画面是否会自动启动菜单活动?如果是这样,您可能需要使用
startActivityForResult(Intent, int)
启动 MenuActivity。然后在菜单活动中覆盖onBackPressed
并传回一个代码,让主活动知道finish();
并使用onActivityResult(int requestCode, int resultCode)处理它,意图数据)
Android Docs 上的此链接应该帮助。
Does the splash screen automatically start the Menu Actvity? If it does you may want to start the MenuActivity by using
startActivityForResult(Intent, int)
. Then in the Menu activity overrideonBackPressed
and pass back a code letting the Main Activity know tofinish();
and handle it usingonActivityResult(int requestCode, int resultCode, Intent data)
This link on the Android Docs should help.