Android and onSaveInstance and Restore
<p>I have a big problem. I have a activity where I have two imageViews. In onCreate I have List pictures where I have 10 pictures. Every time when I start this activity both imageViews get random picture from List and shows them. For example: When I start activity I can see car and pencil and when I start this activity once again I get elephant and book. 
Now this is my problem. When I start activity and block my phone and after that unlock I get other pictures. I think that onCreate is called again. I create </p>

<pre><code>@Override    
protected void onSaveInstanceState(Bundle savedInstanceState) {   
    super.onSaveInstanceState(savedInstanceState);
}

public void onRestoreInstanceState(Bundle savedInstanceState) {

    if  (savedInstanceState != null) {
        pictureGameLeft.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair().getImageLeft()));
        pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair().getImageRight()));         
    }   
}
</code></pre>

<p>pictureGameLeft and Right that is last images which is shows. 
I write them after onCreate method. 
How I can save last seen picture that if I lock and unlock phone I get the same pictures. Maybe onPause or onStop need called? </p>

<p>edit:
now:            </p>

<pre><code>if (savedInstanceState == null) {
    game = new Game();
    game.initGame();
    addElements(result);

    game.getCurrentLevel().nextPair();

    pictureGameLeft.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
        .getImageLeft()));
    pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
        .getImageRight()));

    mRedrawHandler.sleep(1000);             
} 
else {
    pictureGameLeft.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair(
        .getImageLeft()));
    pictureGameRight.setImageResource(shapesPictures.get(game.getCurrentLevel().getCurrentPair()
        .getImageRight()));
}
</code></pre>

<p>but I get NullPointerException.</p>
