title: java.lang.NullPointerException in onRestoreInstanceState(Bundle) for Button
body: <p>I have created a button in onCreate() method of Activity, and try to change the state of button in 
  onRestoreInstanceState(Bundle) method.
  I have only one line in this method.</p>
  
  <pre><code>@Override
  protected void onRestoreInstanceState(Bundle savedInstanceState)
  {
  savedButton.setSelected(true);
  super.onRestoreInstanceState(savedInstanceState);
  }
  </code></pre>
  
  <p>but some time java.lang.NullPointerException exception occur at this line where I have change the button state, and some time it works fine.</p>
  
  <p>Where I am wrong?</p>
  
  <p>Log:</p>
  
  <pre><code>java.lang.NullPointerException
      at com.test.MainActivity.onRestoreInstanceState(MainActivity.java:35)
      at android.app.Activity.performRestoreInstanceState(Activity.java:934)
      at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1145)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2088)
      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
      at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3576)
      at android.app.ActivityThread.access$800(ActivityThread.java:143)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:137)
      at android.app.ActivityThread.main(ActivityThread.java:4950)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:511)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>