简体   繁体   English

从Stack onResume弹出活动

[英]Pop Activity From Stack onResume

When my program starts, it runs a mainActivity, which right away launches and loads data into another Activity. 当我的程序启动时,它运行一个mainActivity,它立即启动并将数据加载到另一个Activity中。 I do this because the data needs only be loaded once, in mainActivity, then sent along to the other activities! 我这样做是因为数据只需要在mainActivity中加载一次,然后发送到其他活动!

So! 所以! With that being said, my problem is probably forseeable! 话虽如此,我的问题可能是可以预见的! When the user clicks back enough, he will get to this initial activity, and sit there... ungracefully, instead of going back to Android's main menu. 当用户单击足够多的位置时,他将进入此初始活动,然后坐在那里……不友好,而不是返回Android的主菜单。

What I want to do is add something to the onResume() method of the mainActivity, so that when it is re-entered I "activate" the back button from within the code-- (a boolean flag makes sure I'm not doing this incorrectly, thus I know it was on a back click). 我想做的是向mainActivity的onResume()方法中添加一些内容,以便重新输入该代码时,我可以从代码内“激活”后退按钮-(一个布尔标志确保我没有这样做这是错误的,因此我知道它是在单击后单击)。 So isn't this just popping the current Activity from the Activity Stack? 那么,这不只是从活动堆栈中弹出当前活动吗?

how do I pop an activity from the activity stack! 如何从活动堆栈弹出活动!

Thanks! 谢谢!

除了使用“ noHistory”属性,您还可以在启动下一个活动时调用finish()。当您单击“后退”按钮时,它不会重新出现。这将关闭第一个活动。从堆栈..

不使用任何历史记录选项,这样该活动就永远不会进入后退堆栈。

android:noHistory=["true" | "false"] 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM