I have a problem I hope someone can help me.
I have several activities
MainActivity, Activity1, Activity2, Activity3
MainActivity let's say it's a list and activities 1 to 3 are forms, in activity3 when a save ends I need to return to the MainActivity, but if I use finish I only return to the previous one, I don't want to use startActivity because when they hit the button from the phone "return" would return to Activity3.
Thanks.
To achieve what you want you first have to indicate that your main activity will have only one instance using the attribute
android:launchMode
on themanifest.xml
.For example:
So when you need to return to your activity you call it using the method
startActivity
:FLAG_ACTIVITY_CLEAR_TOP
what it does is remove the stack of active activities.