title: Why is there no screenshot in recent apps when finnishing activity in firebase onAuthStateChanged
body: <p>I got a very basic splashscreen activity:</p>
  
  <pre><code>@Override
  protected void onCreate(@Nullable Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_start);
  
      FirebaseAnalytics.getInstance(this);
  
  
      mAuth = FirebaseAuth.getInstance();
      mAuth.addAuthStateListener(new FirebaseAuth.AuthStateListener() {
          @Override
          public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
              FirebaseUser user = firebaseAuth.getCurrentUser();
              if (user != null) {
                  FirebaseAuth.getInstance().removeAuthStateListener(this);
                  startActivity(new Intent(StartActivity.this, MainActivity.class));
                  finish();
              }
          }
      });
  }
  </code></pre>
  
  <p>This splash screen opens my <code>MainActivity</code>. When I close this activity this is the screenshot in recent apps:</p>
  
  <p><a href="https://i.stack.imgur.com/07XDm.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/07XDm.jpg" alt="enter image description here"></a></p>
  
  <p>It seems like it is making a screenshot just too late, which results in this nested recent apps screenshot. This also happen on an actual device. How can I solve this weird behaviour?</p>
  
  <p>Activies manifest:</p>
  
  <pre><code>&lt;activity
      android:name="activities.StartActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait"&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="activities.MainActivity"
      android:label="@string/app_name"
      android:screenOrientation="portrait"
      android:launchMode="singleTask"&gt;
  &lt;/activity&gt;
  </code></pre>
  
  <p>The problem seems not the be in the <code>launchMode</code>. I keep having the same behaviour. Even when removing the lauchmode. </p>
  
  <p>It has absolutely something to do with the callback. When starting the activity directly, there is no problem.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I kind a found a solution. Using a delay in starting the activity resolves it. Although a hardcoded delay isn;t that nice.</p>
  
  <pre><code>new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
          startActivity(new Intent(StartActivity.this, MainActivity.class));
          finish();
      }
  },500);
  </code></pre>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I do not get this behaviour when directly starting the activity. So it probably has something to do with the callback. I'm using google sign-in. It looks like some transparent activity is being closed. Could this be the Google Sign-in Activity?</p>