0

I have an android project with a bunch of nested activities :-

Main --- Page 1 --- Page 2 --- Page 3

Main calls page 1. Page 1 can call page 2 or go back to main. Page 2 can call page 3 or go back to page 1. Page 3 can only go back to Main. On returning to main all the other activities have to closed, not hidden.

Now after hours of searching the usual suggestion is Intent.FLAG_ACTIVITY_CLEAR_TOP. This doesn't do what I want though, as it seems to hide the activities, and bring Main to the front, rather than close them and leave only Main open.

Is there a way I can get Page 3 to CLOSE Page 1, 2 and 3, and leave just Main open?

Thanks

STeve

MagicWand
  • 392
  • 1
  • 6
  • 19
  • Using `FLAG_ACTIVITY_CLEAR_TOP` is the correct way to do this. Anything else is overkill or a hack. You must be doing something strange if it doesn't work. Can you post your pmanifest? – David Wasser Nov 30 '16 at 10:51
  • im afraid not. Despite the fact the file is formatted as stack overflow requests, it wont let me upload the edit claiming it isnt formatted correctly. – MagicWand Nov 30 '16 at 12:19

1 Answers1

0

Maybe have a look at Broadcast Listeners: Finish an activity from another activity

It'd probably use the least resources when you finish your page 2 when creating page 3 and at the same time broadcast to your page 1 to finish. This way you might also prevent hiccups when going back from page 3 while page 1 and 2 are finishing.

Community
  • 1
  • 1
Aram Becker
  • 2,026
  • 1
  • 20
  • 32