Overriding Activity / Task behavior in Android

I am writing a simple Android application, and I would like to better control the navigation / relationships between actions. I donโ€™t want my actions to act like android actions ... I donโ€™t want them to work out in the Task. I want one Activity (let it MainActivity ) be the landing point and always be at the bottom of the stack, and I want only one instance of my second action (call it SecondActivity ) to be higher than it on the stack ... it would be nice to reuse it . I thought I could achieve this behavior by making MainActivity the "primary" Activity and declaring them as launchMode=singleTop . This does not work at all. I provide navigation between them using the menu, so when I go back and forth, a bunch of times back and forth from the application, I look at the entire stack.

What is the best way to have excellent control over the Task Activity stack? I want MainActivity to always return from the application and SecondActivity to always return to the same instance of MainActivity. Also, I would like to get singleTop so that I use onNewIntent instead of creating and destroying each time. Using the manifest as well as the intent flag just doesn't work. Any ideas?

+1
source share
1 answer

Well, you can always just call "finish ()" to the extent that Activity calls another action after calling "startActivity ()". I would definitely advise you not to try to stuff the entire application into two activity classes and try to exchange views based on what they do. If this is important to you, just close your actions when starting new ones (obviously not MainActivity).

+2
source

All Articles