I have a levels.java file where the user can pick one of 3 levels, then when his choice is made I run this code:
startActivityForResult (new Intent(this, GameScreen.class),requestCode);
which displays the user the “game screen” where he can play for a while, the game is a simple timer game (as I am a noob learning Android) and has a pause function if the user wants to take a break.
I also call the pause function if the user hits the back button on the phone.
My problem is, when the user hits the pause function, does whatever he wants to do then comes back to my app, it shows him the levels.java screen and when he selects to go back into the game it starts a new gamescreen, it does not go back to the paused screen 🙁
Which means any points etc he may have made is gone.
How do I go back to the same screen that he was on before?
In other words:
If old activity is still running return to it, if not start a new activity. But… how?
Thanks!
R
EDIT: The code I run if the user clicks the pause button:
if (r_settings.getPausedValue() == false) {
ib7.setClickable(false);
ib2.setClickable(false);
ib1.setClickable(false);
r_settings.setPausedValue(true);
main_image.setImageResource(R.drawable.game_paused);
Basically, check if the game is already paused, if not, disable buttons, set paused value to true, show a graphic that says “Game paused” in the middle of the screen.
Try this: