Ofek Ron
Ofek Ron

Reputation: 8580

Changing Actiivity Stack Behavior

Well i have 2 activities, say A and B, user zipping between them like crazy A then going to B then A etc, now i dont want the normal behavior of zipping back to home through all those "layers" of A and B.

I want that if the user is in A it will go back to Home, if he is in B he will go back to A, and i want to do that as traditional and system friendly as possible - which means that i dont want workarounds that would fill my Activity stack nor do i want to start activities on new tasks.

i have tried using android:clearTaskOnLaunch="true" on activity A, and as it is documented it seems like the best thing to do, but it doesnt provide the documented behavior - it is behaving the same as it did without it...

what do you suggest?

Upvotes: 1

Views: 70

Answers (1)

Squonk
Squonk

Reputation: 48871

If you use finish() in B after it starts A then B will self terminate...

startActivity(new Intent(this, ActivityA.class));
finish();

Upvotes: 1

Related Questions