导航回到主页活动
我要求应用程序在每个活动中设置一个按钮
以返回到HomeActivity
,但我不应该不重新加载它的内容,所以我需要重新使用已有的 HomeActivity
实例,我该怎么做?
I've requirement for application to set a Button
in every activity to go back to HomeActivity
but I should Not Reload the content for it, so I need to re-use the instance I already have of HomeActivity
, how I could do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用: FLAG_ACTIVITY_REORDER_TO_FRONT
http://developer.android.com/reference/ android/content/Intent.html#FLAG_ACTIVITY_REORDER_TO_FRONT
You should use: FLAG_ACTIVITY_REORDER_TO_FRONT
http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_REORDER_TO_FRONT
我在活动中使用了
FLAG_ACTIVITY_CLEAR_TOP
作为主页按钮。如果您的HomeActivity
已位于应用程序堆栈中,则此标志会导致HomeActivity
之上的所有活动关闭。这取决于您是否需要将HomeActivity
重新排序到前面(后退按钮将使您返回到单击主页的 Activity),或者您想要关闭HomeActivity
上方的所有 Activity(就像点击返回直到进入HomeActivity
一样,在我的例子中,“后退”按钮会从我的家庭活动中关闭应用程序)。http://developer.android.com/reference/android/content/Intent .html#FLAG_ACTIVITY_CLEAR_TOP
I used
FLAG_ACTIVITY_CLEAR_TOP
for home button in my activities. If you have yourHomeActivity
already in application stack, this flag causes close of all activities above yourHomeActivity
. It depends if you need to reorderHomeActivity
to front (Back button will return you back to activity where you clicked home) or you want to close all activities that are aboveHomeActivity
(like clicking back until I'm inHomeActivity
, in my case Back button closes application from my home activity).http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP