I\'ve made the majority of my game\'s mechanics, I now need to be able to:
Save all the data of the current activity and <
The onSaveInstanceState will not be called when you press back key to finish it. To save your data all the time you have to use onPause as the code shows:
@Override
public void onPause() {
super.onPause();
SharedPreferences sp = getSharedPreferences("X", Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.putString("lastActivity", HomeActivity.class.getCanonicalName());
}
Remember to replace HomeActivity with your own class name.BTW, I didn't test the function getCanonicalName, but it should work.
In your Dispatch Activity, you read the value back and do some action to it.