Android How to switch between intentions

I have 3 events. start / game / finish, I want to start the game, finish the game, finish to start. but when I use Intent one to the other, when I finish () “finish”, it returns to the game. He must return to the beginning. so he needs to design any Intents at the start of the activity.

so I tried this and expected when I finish () to “finish” the application will be destroyed, but it did not work

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

Q: since I can start finishing Intent activity at the beginning, but from game activity

+1
source share
2 answers

When you call startActivity(...) in the “game” of an Activity to start the “finish” of an Activity , immediately call finish() to stop the “game”. If you do this, then the BACK in the "finish" Activity will return to "start" because the "game" is self-closing.

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

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

0
source

Source: https://habr.com/ru/post/906180/


All Articles