Fragments in Android support library: getLastCustomNonConfigurationInstance/onRetainCustomNonConfigurationInstance magic
<p>I have a simple class that extends FragmentActivity. I use getLastCustomNonConfigurationInstance/onRetainCustomNonConfigurationInstance for save current state. </p>

<pre><code>public class MyActivity extends FragmentActivity {

    static class Saver {
        // ...
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        Saver saver = (Saver) getLastCustomNonConfigurationInstance();
        if (saver != null) {
            // ...
        } 
        // ...

    }

    @Override
    public Object onRetainCustomNonConfigurationInstance() {
        Saver saver = new Saver();
        // ...
        return saver;
    }
}
</code></pre>

<p>And when I close this activity I've got sometimes a strange exception such as:</p>

<pre><code>java.lang.ClassCastException: Saver cannot be cast to android.support.v4.app.FragmentActivity$NonConfigurationInstances

at android.support.v4.app.FragmentActivity.getLastCustomNonConfigurationInstance(FragmentActivity.java:576)
...
</code></pre>

<p>What do you think about this problem? Thanks in advance!</p>
