I am making a game, and I want my app to restart when it is selected in the recents menu. So if mid-game, the player presses the home button the app would open fresh again. I tried this earlier but to no avail.
@Override
public void onResume(){
super.onResume();
}
@Override
public void onPause(){
super.onPause();
onStop();
onDestroy();
}
What do I put in the onResume() method?
I'd recomend you to do nothing special onPause()
because at that callback activity could be still visible to the user and it could be confusing, see docs.
Instead of this try to use onStop()
:
@Override
protected void onStop(){
super.onStop();
finish();
}
Also you can try to recreate your game objects when user navigates back to the game on onRestart()
of your activity.