自定义返回导航 [英] Customize back navigation
问题描述
首先我阅读了这篇文章但有点对我来说很复杂.我所需要的只是在 onBackPressed() 覆盖中转到我想要的活动(如果存在于后堆栈中,则导航或使用 Intent 启动它).我应该管理后台堆栈吗或者是其他东西 ?如果是怎么办?如果没有,那么简单的方法是什么?
First of all I read this article but is kind of complicated for me . All I need is to go to an activity I want (navigate if exist in back stack or start it with Intent if it's not ) in onBackPressed() override . should I manage back stack or something else ? if yes how ? and if no what is a simple way for that ?
P.S : 我不使用 ActionBar
P.S : I dont use ActionBar
推荐答案
SOLVED: as 在这个答案中提到并根据对于评论,如果我们只想将(现有的)Activity 放在前面,请将 Intent 标志设置为:
SOLVED: as mentioned in this answer and according to comments , if we want to just bring an (existing )Activity to front , setting Intent flag to :
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
不会创建我们想要的 Activity 的新实例,而只是把它放在前面.如果我们在一个 Activity 之上有多个 Activity,这将非常有用.
wont create new instance of Activity we want and just bring it front . this would be useful if we have multiple activities on top of the one .
这篇关于自定义返回导航的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!