In my own project, I need to use Intent.flag_activity_new_task | Intent.flag_activity_clear_task to start a new activity and remove all previous activity. The code I use for this intent flag is as follows:
<span style= "White-space:pre" ></span>intent Intent = new Intent (gerenxinxi.this, Mainpart.class); Intent.setflags (Intent.flag_activity_new_task | Intent.flag_activity_clear_task); startactivity (Intent); Finish ()
But when I execute this code, I find that there will be a period of black screen (very short, but I can clearly feel it). I tried to put Intent.setflags (Intent.flag_activity_new_task | Intent.flag_activity_clear_task); This line of code is removed and a black screen is found to be missing. In order to test the use of other flags, such as flag_activity_clear_top, there is no black screen, but according to the requirements I have to use the Intent.flag_activity_new_task | Intent.flag_activity_clear_task. Later through their own search and test, found that the following method can be removed from the black screen.
If it is shown in the above code that the activity jumps from Gerenxinxi to Mainpart, then the configuration of our Mainpart in androidmanifest should look like this:
<span style= "White-space:pre" ></span><activity android:name= " Com.ci123.jiayuanbao.school.MainPart " android:screenorientation=" Portrait " android:theme=" @style/ Apptheme_yu "> </activity>
At the same time, in style we want to configure style:
<span style= "White-space:pre" ></span><style name= "Apptheme_yu" parent= "@android: Style/Theme.Light" > <span style= "White-space:pre" ></span><item name= "Android:windownotitle" >true</item > <span style= "White-space:pre" ></span><item name= "Android:animationduration" >0</ item> <span style= "White-space:pre" ></span><item name= "Android:windowdisablepreview" > True</item></style>
The main is <item name= "Android:windowdisablepreview" >true</item>, can be removed before the black screen appeared.
This is the question that I ask on the net, others reply link: http://stackoverflow.com/questions/31264157/ How-to-avoid-black-screen-when-intent-flag-activity-new-task-intent-flag-activ
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
How to avoid using Intent.flag_activity_new_task | Black screen problem after intent.flag_activity_clear_task