Hrm, changed that but didn't seem to help.

On Jun 29, 5:31 pm, Kostya Vasilyev <[email protected]> wrote:
> Your "put" and "get" operations use different keys:
>
> this.gameState.getClass().getName() // Can vary with the actual class of
> gameState
>
> and
>
> GameState.class.getName() // Always "GameState"
>
> presumably you have various subclasses of GameState, so there is a
> mismatch and thus "gameState.setState()" crashes with a null pointer.
>
> Just define a string constant and use it as the key in both places:
>
> private static final String GAME_STATE_KEY =
> "com.wright.james.GAME_STATE_KEY";
>
> b.putParcelable(GAME_STATE_KEY, gameState)
>
> and
>
> gameState = bundle.getParcelable(GAME_STATE_KEY)
>
> -- Kostya
>
> 28.06.2011 7:18, JamesWrightпишет:
>
> >    protected void onSaveInstanceState(Bundle b) {
> >            b.putParcelable(this.gameState.getClass().getName(),
> > this.gameState);
> >            super.onSaveInstanceState(b);
> >    }
>
> > and retrieved in Activity's OnCreate as follows:
>
> >            if (bundle != null&&  !bundle.isEmpty()) {
> >                    gameState = (GameState) 
> > bundle.getParcelable(GameState.class
> >                                    .getName());
> >                    gameState.setState(State.REGULAR);
> >            }
>
> --
> Kostya Vasilyev

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to