Maybe fix issue #7132432: com.android.vending: java.lang.IllegalStateException...

...Can not perform this action after onSaveInstanceState at...
...android.support.v4.app.FragmentManagerImpl.checkStateLoss(FragmentManager.java:1300)

ActivityFragment should clear the flag that state is saved when it
receives onNewIntent().  This can happen before the activity is
resumed, so we may not have cleared it yet.  Also need to do the same
thing for onActivityResult().

Change-Id: Ied35e09cdf0196bb17d309bf5f2c04d3d480c9f6
diff --git a/v4/java/android/support/v4/app/FragmentActivity.java b/v4/java/android/support/v4/app/FragmentActivity.java
index 78ddc52..00b124a 100644
--- a/v4/java/android/support/v4/app/FragmentActivity.java
+++ b/v4/java/android/support/v4/app/FragmentActivity.java
@@ -26,7 +26,6 @@
 import android.os.Handler;
 import android.os.Message;
 import android.os.Parcelable;
-import android.support.v4.util.SparseArrayCompat;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.KeyEvent;
@@ -145,6 +144,7 @@
      */
     @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        mFragments.noteStateNotSaved();
         int index = requestCode>>16;
         if (index != 0) {
             index--;
@@ -402,6 +402,22 @@
     }
 
     /**
+     * Handle onNewIntent() to inform the fragment manager that the
+     * state is not saved.  If you are handling new intents and may be
+     * making changes to the fragment state, you want to be sure to call
+     * through to the super-class here first.  Otherwise, if your state
+     * is saved but the activity is not stopped, you could get an
+     * onNewIntent() call which happens before onResume() and trying to
+     * perform fragment operations at that point will throw IllegalStateException
+     * because the fragment manager thinks the state is still saved.
+     */
+    @Override
+    protected void onNewIntent(Intent intent) {
+        super.onNewIntent(intent);
+        mFragments.noteStateNotSaved();
+    }
+
+    /**
      * Dispatch onResume() to fragments.  Note that for better inter-operation
      * with older versions of the platform, at the point of this call the
      * fragments attached to the activity are <em>not</em> resumed.  This means