1

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

Mert
  • 6,432
  • 6
  • 32
  • 68

2 Answers2

4

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();
Squonk
  • 48,735
  • 19
  • 103
  • 135
  • lol, admittedly similar questions are fairly common here on SO but it was a simple one for me to answer and the Android "manual" is quite a big one. In 14 months programming Android I probably only covered 20% of the developers pages and I still get some simple stuff wrong. :) – Squonk Jan 13 '12 at 23:32
0

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

SlowDeepCoder
  • 864
  • 3
  • 11
  • 27
  • I think System.exit(0) completely kills your app, isn't it? – kosa Jan 13 '12 at 22:45
  • I wanna return to start activity from finish activity. but It return to game. – Mert Jan 13 '12 at 22:48
  • As a rule, don't ever use `System.exit(...)`. A call to `finish()` on its own will kill an `Activity` cleanly. – Squonk Jan 13 '12 at 22:50
  • I know system.exit.. but It not even close what I asked as an answer.. I need answer about Intents pls read carefully.. thanks – Mert Jan 13 '12 at 22:52