title: How to avoid black screen on startActivity when FLAG_ACTIVITY_CLEAR_TASK is set?
body: <p>I am launching a new activity using the following:</p>
  
  <pre><code>Intent intent = new Intent(this, MyNewActivity.class);
  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  startActivity(intent);
  overridePendingTransition(0, 0);
  </code></pre>
  
  <p>While <code>MyNewActivity</code> is launching, a black screen is shown.</p>
  
  <p>If I remove <code>Intent.FLAG_ACTIVITY_CLEAR_TASK</code>, the activity is launched without showing a black screen at any moment (instead, the previous activity is shown while the new one loads).</p>
  
  <p>Is there any way to avoid this black screen? Removing the flags seems to not be an option (I need to clear all the current task's stack and launch a new activity as the root one).</p>
  
  <p><strong>EDIT:</strong> I attach a very simple code which reproduces the issue (set a dark theme such as <code>Theme.AppCompat</code> for the app). The black screen is shown for very little time (depends on how many work the receiving activity does when launching), but you can see it. If you don't use <code>FLAG_ACTIVITY_CLEAR_TASK</code>, the black screen is not shown and the transition is smooth:</p>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code>public class MainActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent intent = new Intent(MainActivity.this, MyNewActivity.class);
                  intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                  startActivity(intent);
                  overridePendingTransition(0,0);
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>MyNewActivity</strong></p>
  
  <pre><code>public class MyNewActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_new);
      }
  }
  </code></pre>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/holo_blue_bright"&gt;
  
      &lt;Button
          android:id="@+id/button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="CLICK ME!" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><strong>activity_new.xml</strong></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:background="@android:color/holo_green_light"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="I am the new activity!" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>Thanks!</p>