How to avoid using Intent.flag_activity_new_task | Black screen problem after intent.flag_activity_clear_task

Source: Internet
Author: User

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&gt, 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

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.