Here's what I want to do:
If I use startActivity
I start a new Activity and I can't use StartActivityForResult from Main Menu -> Total. I would like to go back on the Main Menu activity already present in my stack and remove Activities A, B ,C and Total.
In the second activity, the back button at the top left can be used to go back to the previous activity.
Android activities are stored in the activity stack. Going back to a previous activity could mean two things. You opened the new activity from another activity with startActivityForResult. In that case you can just call the finishActivity() function from your code and it'll take you back to the previous activity.
If you just want to reload the activity, for whatever reason, you can use this. recreate(); where this is the Activity. This is never a good practice. Instead you should startActivity() for the same activity and call finish() in the current one.
Have you tried using FLAG_ACTIVITY_CLEAR_TOP
flag in your intent (used to start "Main Menu" from "Total")?
http://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_TOP
If set, and 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With