0

I have an app that starts with Activity A. Among other things user can go to Activity B and return with the back button.

User can start Activity A also from Activity B using a Menu. This brings Activity A to Front again.

intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);

Problem is: Activity A should be Home Activity. Pressing back needs to always quit the application.

Currently back will go back to Activity B, then finish.

Using FLAG_ACTIVITY_CLEAR_TOP will destroy Activity B, which I do not want as the user should find the activity where he left it (e.g. scrolling position; unless android destroyed it for memory reasons).

I just want to leave the application on back pressed on Activity A. How can I do that?
Can I clear the backstack without destroying the activities?

As an alternative I could override onBackPressed in Activity A to quit the app, but how do I exit the application? Using finish() will only close current activty an bring back other open activities. Do I nees a broadcast as suggested here: Clear Activity back stack?

Community
  • 1
  • 1
Gunnar Bernstein
  • 6,074
  • 2
  • 45
  • 67
  • it seems that your problem comes from the fact, that you start activity A from the menu in activity B. Can't you instead just finish activity B and show again Activity A. If you need to pass data, you can start it with startActivityForResult anyways – peshkira Apr 07 '14 at 14:36
  • I know where the problem comes from and that I could avoid it, but " user should find the activity where he left it (e.g. scrolling position" – Gunnar Bernstein Apr 07 '14 at 17:13

0 Answers0