我有一些活动.
Home Activity -> Activity 1 -> Activity 2 -> Activity 3 -> HomeActivity finish(); finish(); finish(); Home Activity -> Activity 1 -> Activity 2 -> Activity 3 -> Activity 4 -> HomeActivity finish(); finish(); finish(); finish();现在,当我进入HomeActivity的最后一步时,如果按后退"按钮,它将再次带我进入家庭活动.
So now when I am on the final step that is on the HomeActivity if I press back button it again takes me on to the home activity.
如何完成家庭活动而不干扰整个过程?任何帮助表示赞赏.
How do I finish the home activity without disturbing the whole process? Any help appreciated.
推荐答案将此标志与您在每次活动中的意图结合使用
use this flag with your intent in each activity
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);这将不会再次启动家庭活动.它将使用您的家庭活动的先前实例并将其显示在顶部.
This will not launch home activity again . It will use the previous instance of you Home Activity and bring it to top.
with CLEAR_TOP如果正在启动的活动已经在当前任务中运行,那么与其启动该活动的新实例,不如关闭该活动之上的所有其他活动,并将此Intent传递给(现在最重要)旧活动作为新的Intent.
with CLEAR_TOP If the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.
您可以参考此链接以获得有关标志的更多信息.
You can refer this Link to get more idea about flags.
更多推荐
完成android中的活动?
发布评论