android go back to first screen

2019-04-06 18:14发布

I have an android app with links (made by linkify) that lead into other screens of my app. I'm wondering what's the best approach to close all of the 'child' activities and go back to the first activity that was originally launched.

in otherwords something like this:

HomeScreenActivity => Screen1 (via Linkify-link) => Screen2 => Screen3 => click home => (close screens 1, 2 & 3) => HomeScreenActivity

2条回答
Anthone
2楼-- · 2019-04-06 18:22

You could start Screen3 with startActivityForResult in Screen2. When you want to go back to screen1 from screen3 you return a result that let's Screen2 call finish() and you call finish() yourself in Screen3.

查看更多
该账号已被封号
3楼-- · 2019-04-06 18:28

You should be able to accomplish this by creating an intent for your HomeScreenActivity with the FLAG_ACTIVITY_CLEAR_TOP flag.

查看更多
登录 后发表回答