Weird ClassCastException when deserializing in onRestoreInstanceState
<p>In <code>onSaveInstanceState()</code>:</p>

<pre><code>// departures is instance of Departures which extends ArrayList
bundle.putSerializable("departures", departures);
</code></pre>

<p>In <code>onRestoreInstanceState</code>:</p>

<pre><code>departures = (Departures) state.getSerializable("departures");
</code></pre>

<p>When I rotate the screen, the Activity is restarted and it's state is restored. It works ok. In case I leave the Activity, after some time Android removes it from memory and saves its state. When I return to it, it crashes in <code>onRestoreInstanceState</code>:</p>

<pre><code>java.lang.ClassCastException: java.util.ArrayList cannot be cast to cz.fhejl.pubtran.Departures
</code></pre>

<p>The <code>getSerializable</code> now returned <code>ArrayList</code>, not <code>Departures</code>.</p>

<p>Edit: here's how Departures.java looks: <a href="http://pastebin.com/qc3QfrK7" rel="nofollow">http://pastebin.com/qc3QfrK7</a></p>
