How to avoid the black screen problem after Intent. FLAG_ACTIVITY_NEW_TASK | Intent. FLAG_ACTIVITY_CLEAR_TASK, activityintentflag
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 activities. The code for using 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()
However, when executing this code, I found that there would be a black screen period (very short, but obviously ). I tried to remove this line of code from intent. setFlags (Intent. FLAG_ACTIVITY_NEW_TASK | Intent. FLAG_ACTIVITY_CLEAR_TASK). The black screen was lost. Other flags, such as FLAG_ACTIVITY_CLEAR_TOP, are used for testing. However, you must use Intent. FLAG_ACTIVITY_NEW_TASK | Intent. FLAG_ACTIVITY_CLEAR_TASK as required. After searching and testing, we found that the black screen can be removed through the following method.
If the above Code shows a jump from the activity Gerenxinxi to the MainPart, then our mainpart configuration in AndroidManifest should be 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, we need to configure style in 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>
<Item name = "android: windowDisablePreview"> true </item> is used to remove the previous black screen.
This is my online question, someone else reply to the link: http://stackoverflow.com/questions/31264157/how-to-avoid-black-screen-when-intent-flag-activity-new-task-intent-flag-activ
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.