title: Callback after orientation change becomes null
body: <p>I have have a <code>FragmentActivity</code> with two tabs which are <code>ListFragment</code>s. Each <code>ListFragment</code> has a callback.</p>
  
  <p>An example of a callback</p>
  
  <p>The callback is associated inside of the <em>onAttach(...)</em> method</p>
  
  <pre><code>OnStatusUpdateListener mStatusUpdateCallback;
  
  public interface OnStatusUpdateListener {
      public void onStatusUpdate();
  }
  
  @Override
  public void onAttach(Activity activity) {
      Log.d(TAG, "onAttach");
      super.onAttach(activity);
  
      try {
          mStatusUpdateCallback = (OnStatusUpdateListener)activity;
      } catch (ClassCastException e) {
          throw new ClassCastException(activity.toString() + " must implement OnStatusUpdateListener");
      }
  }
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      Log.d(TAG, "onCreate");
      super.onCreate(savedInstanceState);
  
      setRetainInstance(true);
  }
  </code></pre>
  
  <p>Later on, I communicate with the <code>FragmentActivity</code> by this callback which works fine normally.</p>
  
  <p>Within the <code>ListFragment</code>, I have an <code>ImageButton</code> that will call a <code>DialogFragment</code> which also has a callback. This callback is implemented in my <code>ListFragment</code> and is what triggers the callback that is <em>null</em></p>
  
  <pre><code>public void onStatusOption() {
      Log.d(TAG, "onStatusOption");
  
      // Update stuff
  
      // Here is where mStatusUpdateCallback is null after rotate
      mStatusUpdateCallback.onStatusUpdate();
  }
  </code></pre>
  
  <p>The problem is that if I ever rotate the phone while the application is running, <strong>mStatusUpdateCallback</strong> becomes <em>null</em>. This of course means I cannot execute the callback. Does anyone know how to fix this?</p>
  
  <p><strong>What I've tried</strong></p>
  
  <p>According to <a href="https://stackoverflow.com/a/6029070/935779">https://stackoverflow.com/a/6029070/935779</a> it appears that a new reference to <code>OnStatusUpdateListener</code> may have been created so I cannot reference the old, but doesn't offer a solution.</p>
  
  <p>I've also tried retaining the state as per <a href="https://stackoverflow.com/a/6787393/935779">https://stackoverflow.com/a/6787393/935779</a>, but I can't save a reference to a callback as far as I can tell.</p>
  
  <p>I also would really rather not do the <code>android:configChanges="orientation|keyboardHidden"</code> method since that just seems like a hack and my layout changes in landscape.</p>
  
  <p><strong>Stacktrace</strong></p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.NullPointerException
      at com.blug.blah.Fragment.StatusFragment.onStatusOption(StatusFragment.java:197)
      at com.blug.blah.MyActivity.onStatusOption(MyActivity.java:243)
      at com.blug.blah.Dialog.StatusOptionDialog$1$1.onClick(StatusOptionDialog.java:108)
      at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:158)
      at android.os.Handler.dispatchMessage(Handler.java:99)
      at android.os.Looper.loop(Looper.java:123)
      at android.app.ActivityThread.main(ActivityThread.java:4627)
      at java.lang.reflect.Method.invokeNative(Native Method)
      at java.lang.reflect.Method.invoke(Method.java:521)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
      at dalvik.system.NativeStart.main(Native Method)
  </code></pre>