zoukankan      html  css  js  c++  java
  • 怎样避免使用Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK之后的黑屏问题

    在自己的项目中。我须要使用Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK来開始新的activity同一时候移除之前全部的activity。

    我使用这个intent flag的代码例如以下:

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

    可是当运行这段代码的时候,我发现会有一段黑屏的时间段(非常短。可是能非常明显感觉出来)。

    我试着把intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);这行代码去掉,发现黑屏就不见了。为了測试,使用其它的flag。如FLAG_ACTIVITY_CLEAR_TOP等均没有发生黑屏的情况,可是依据需求我又必需要使用Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK。后来经过自己的查找和測试,发现通过以下的方法能够去掉黑屏。


    假设是像上面的代码那样所展现的是从Gerenxinxi这个activity跳转到MainPart。那么我们在AndroidManifest里的mainpart的配置应该是这种:

            <activity
                android:name="com.ci123.jiayuanbao.school.MainPart"
                android:screenOrientation="portrait"
                android:theme="@style/AppTheme_yu" >
            </activity>

    同一时候,在style里我们要配置style:

          <style name="AppTheme_yu" parent="@android:style/Theme.Light">  
             <item name="android:windowNoTitle">true</item>  
             <item name="android:animationDuration">0</item>
             <item name="android:windowDisablePreview">true</item>
          </style>   
    主要是<item name="android:windowDisablePreview">true</item>。能够去掉之前所出现的黑屏。

    这是我在网上问的问题。别人回复的链接:http://stackoverflow.com/questions/31264157/how-to-avoid-black-screen-when-intent-flag-activity-new-task-intent-flag-activ

  • 相关阅读:
    PHP获取指定的时间戳
    Thinkphp实现excel数据的导出
    ThinkPHP按月统计订单总金额
    PHP获取本月起始和终止时间戳
    ThinkPHP 判断一个更新操作是否成功
    js 通过浏览器直接打开应用程序(IOS,Android)并判断浏览器内核
    ThinkPHP 后台管理删除、编辑操作(通过数组传ID)
    PHP面向对象
    【转】Chrome调试鼠标悬停后出现的元素
    【重要】Selenium2+python自动化44-元素定位参数化(find_element)
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6906179.html
Copyright © 2011-2022 走看看