Reputation: 8992
I have 3 Activities
, Activity A, B, & C
. From ActivityA
, I click on a button
to launch ActivityB
and within ActivityB
I click another button
to launch ActivityC
.
I am trying to figure out the proper way to return to ActivityA
from ActivityC
with optional return to ActivityB
from ActivityC
.
If I am in ActivityC
and click the home button
I want to return to ActivityB
, but if I click my 'save' button
I want to finish ActivityC
& ActivityB
and show ActivityA
.
How can I accomplish this?
Answer Edit: As krishna murali's suggested in his answer, he was about 99% of the way there. These two flags did the trick Intent.FLAG_ACTIVITY_CLEAR_TOP
& Intent.FLAG_ACTIVITY_SINGLE_TOP
Upvotes: 1
Views: 982
Reputation: 823
On Click of your button to return to ActivityA from ActivityC. Use this:
Intent intent = new Intent(getApplicationContext(), ActivityA.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
This will clear all the activities on top of ActivityA.
Upvotes: 4