How to avoid the black screen problem after Intent. FLAG_ACTIVITY_NEW_TASK | Intent. FLAG_ACTIVITY_CLEAR_TASK, activityintentflag

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.