Avoiding a black screen when Intent.FLAG_ACTIVITY_NEW_TASK | Is Intent.FLAG_ACTIVITY_CLEAR_TASK set?

In my Android app, I need to use Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK to set my goal flag. I can delete all previous Activities and start a new Activity in this way. This is my code below:

 Intent intent = new Intent(Gerenxinxi.this, MainPart.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent); finish(); overridePendingTransition(0,0); 

However, when I used the code above, I detected a flickering black screen. If I did not set the intent flag with Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK , the flicker of the black screen will disappear. My question is: what can I do to avoid a black screen when Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK set Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK ?

Before writing this question down, I found that someone has a similar question. This is a link. However, the answers to this question cannot solve my problem. So I ask the question again. I hope someone can help me. Thanks.

+6
source share
3 answers

This initial screen that you see is called a preview screen. You can completely disable this by declaring this in your subject:

 android:windowDisablePreview <style name="Theme.MyTheme" parent="android:style/Theme.Holo"> <!-- This disables the black preview screen --> <item name="android:windowDisablePreview">true</item> </style> 
+20
source

only one solution, I found it instead of showing a black screen of the application. in my case its white

  <application android:name="com.my.MyApplication" android:allowBackup="true" android:icon="@drawable/launcher" android:label="@string/app_name" android:theme="@style/Theme.MyTheme"> <style name="Theme.MyTheme" parent="android:style/Theme.Holo"> <!-- This disables the black preview screen --> <item name="android:windowDisablePreview">true</item> </style> 
0
source

try it

 Intent intent = new Intent(Gerenxinxi.this, MainPart.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); 
0
source

All Articles