In onSaveInstanceState():
// departures is instance of Departures which extends ArrayList
bundle.putSerializable("departures", departures);
In onRestoreInstanceState:
departures = (Departures) state.getSerializable("departures");
When I rotate the screen, the activity restarts and the state is restored. It is working fine. If I leave the event, after a while Android will delete it from memory and save its state. When I get back to him, it will work in onRestoreInstanceState:
java.lang.ClassCastException: java.util.ArrayList cannot be cast to cz.fhejl.pubtran.Departures
getSerializablenow returns ArrayList, not Departures.
Edit: here is what Departures.java looks like: http://pastebin.com/qc3QfrK7
source
share