Mert
Mert

Reputation: 6572

android How to switch between Intents

I have 3 activities. start / game / finish, I want to go start to game, game to finish, finish to start. but when I use Intent one to another when I finish() "finish" Its come back to game. It should come back to start. so It needs a design kind of all Intents under start activity.

so I tried this one and expected when I finish() "finish" application will be destroy but It didnt work

Intent intent = new Intent(getApplicationContext(),FinishScreen.class); 
startActivity(intent);

Q: so how can I start finish activity Intent under start activity but from game activity

Upvotes: 1

Views: 519

Answers (2)

Squonk
Squonk

Reputation: 48871

When you call startActivity(...) in "game" Activity to start the "finish" Activity, immediately call finish() so "game" terminates. If you do that then BACK in the "finish" Activity will return to "start" because "game" self-terminated.

Intent intent = new Intent(getApplicationContext(),FinishScreen.class); 
startActivity(intent);
finish();

Upvotes: 4

SlowDeepCoder
SlowDeepCoder

Reputation: 882

The finish() method should work, try with: System.exit(0);

Upvotes: 0

Related Questions