NO , what is done is to save the data in preferences this to generate the Activity again but it is not possible to save an Activity.
What you can do is save the name of Activity
in preferences as String and use this to open the Activity in this way:
startActivity(this, Class.forName("<nombre ultima Activity>"));
To save and get the name of the Activity in preferences you can use the methods:
private String PREFS_KEY = "mispreferencias";
public void saveNombreActivityPref(Context context, String nombreActivity) {
SharedPreferences settings = context.getSharedPreferences(PREFS_KEY, MODE_PRIVATE);
SharedPreferences.Editor editor;
editor = settings.edit();
editor.putString("nombreActivity", nombreActivity);
editor.commit();
}
public String getNombreActivityPref(Context context) {
SharedPreferences preferences = context.getSharedPreferences(PREFS_KEY, MODE_PRIVATE);
return preferences.getString("nombreActivity", "");
}
Save name (you could implement it in the onDestroy () of the Activity):
protected void onDestroy(){
super.onDestroy();
//Guarda nombre de Activity.
saveNombreActivityPref(getApplicationContext(), nombreActivityActual) {
}
gets name and opens Activity
:
//Obtiene nombre.
String nombreUltimaActivity = getNombreActivityPref(getApplicationContext());
//Abre Activity.
startActivity(this, Class.forName(nombreUltimaActivity));