By not seeing the code, I can only suggest you use onSaveInstanceState ()
Basically what it does is to rebuild your activity after having finished it for the life cycle that your app uses, either for a finish or for simply closing the app. The activity is reconstructed with pre-stored values in the object Bundle
, which will serve to recover the data that will inflate that Activity again.
To save additional information about the status of the activity,
you must replace the callback method
onSaveInstanceState (). The system calls this method when the
user is abandoning your activity and passes the Bundle object that
will be saved in case your activity is destroyed in a
unexpected If more later the system must recreate the
instance of the activity, this passes the same object Bundle to the
methods onRestoreInstanceState () and onCreate ().
Hint of code provided by the documentation
To save additional status information for your activity, you must implement onSaveInstanceState()
and add key-value pairs to the Bundle object. For example:
static final String STATE_SCORE = "playerScore";
static final String STATE_LEVEL = "playerLevel";
...
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {
// Save the user's current game state
savedInstanceState.putInt(STATE_SCORE, mCurrentScore);
savedInstanceState.putInt(STATE_LEVEL, mCurrentLevel);
// Always call the superclass so it can save the view hierarchy state
super.onSaveInstanceState(savedInstanceState);
}
Here's how you can restore certain status information in onCreate()
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // Always call the superclass first
// Check whether we're recreating a previously destroyed instance
if (savedInstanceState != null) {
// Restore value of members from saved state
mCurrentScore = savedInstanceState.getInt(STATE_SCORE);
mCurrentLevel = savedInstanceState.getInt(STATE_LEVEL);
} else {
// Probably initialize members with default values for a new instance
}
...
}
To pass a new String variable to the activity that you want to see again, just use putExtra ()
I hope it serves you.