title: Crash when starting activity in Android 10
body: <p>I'm facing an issue when running my app (min SDK 21) on Android 10 (SDK 29).</p>
  
  <p>The app's initial activity is coming up and showing as expected. Now, when pressing a button to bring up a second activity on top, I see this crash log:</p>
  
  <pre><code>java.lang.IllegalStateException: Activity top position already set to onTop=false
      at android.app.ActivityThread.handleTopResumedActivityChanged(ActivityThread.java:4370)
      at android.app.servertransaction.TopResumedActivityChangeItem.execute(TopResumedActivityChangeItem.java:39)
      at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
      at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
      at android.os.Handler.dispatchMessage(Handler.java:107)
      at android.os.Looper.loop(Looper.java:214)
      at android.app.ActivityThread.main(ActivityThread.java:7356)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
  </code></pre>
  
  <p>The second activity is starting up fine for all Android versions below SDK 29. The code is as simple as </p>
  
  <pre><code>    this.startActivity (new Intent (MyFirstActivity.this, MySecondActivity.class));
  </code></pre>
  
  <p>Any hint on what might trigger this issue and what the exception ("Activity top position already set to onTop=false") is actually telling me?</p>
  
  <p>This is the ActivityThread.java code for your convenience:</p>
  
  <pre><code>@Override
  public void handleTopResumedActivityChanged(IBinder token, boolean onTop, String reason) {
      ActivityClientRecord r = mActivities.get(token);
      if (r == null || r.activity == null) {
          Slog.w(TAG, "Not found target activity to report position change for token: " + token);
          return;
      }
      if (DEBUG_ORDER) {
          Slog.d(TAG, "Received position change to top: " + onTop + " for activity: " + r);
      }
      if (r.isTopResumedActivity == onTop) {
          throw new IllegalStateException("Activity top position already set to onTop=" + onTop);
      }
      r.isTopResumedActivity = onTop;
      if (r.getLifecycleState() == ON_RESUME) {
          reportTopResumedActivityChanged(r, onTop, "topStateChangedWhenResumed");
      } else {
          if (DEBUG_ORDER) {
              Slog.d(TAG, "Won't deliver top position change in state=" + r.getLifecycleState());
          }
      }
  }
  </code></pre>
  
  <p>Here is an excerpt from AndroidManifest:</p>
  
  <pre><code>&lt;application
      ...
  
      &lt;activity
          android:name="com.xxx.MyFirstActivity"
          android:label="@string/${applicationLabel}"
          android:launchMode="singleTask" 
          android:configChanges="orientation|keyboardHidden|screenSize" &gt;
  
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
  
      &lt;/activity&gt;
  
      ...
  
      &lt;activity
          android:name="com.xxx.MySecondActivity"
          android:label="@string/ls_Quick_Reference"
          android:icon="@drawable/action_help"  &gt;
      &lt;/activity&gt;
  
      ...
  
  &lt;/application&gt;
  </code></pre>