美文网首页
Intent.FLAG_ACTIVITY_NEW_TASK |

Intent.FLAG_ACTIVITY_NEW_TASK |

作者: 陈萍儿Candy | 来源:发表于2020-09-04 19:41 被阅读0次
Intent intent = new Intent();
intent.setClass(App.getInstance().getContext(), LoginActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
App.getInstance().getContext().startActivity(intent);

从一个acitvity启动到LoginActivity.,中间出现黑屏
解决方法:LoginActivity设置一个theme,这个theme中的<item name="android:windowDisablePreview">true</item>
设置为true
them主题如下

<style name="test_no_black_green" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:windowDisablePreview">true</item>
</style>

清单文件如下

<activity
    android:name=".user.login.LoginActivity"
    android:launchMode="singleTask"
    android:screenOrientation="portrait"
    android:theme="@style/test_no_black_green" />

https://blog.csdn.net/y505772146/article/details/46800825

为什么windowDisablePreview设置为true就可以避免黑屏?
可以看下:https://www.jianshu.com/p/de7e2f0d9f20
和预览窗口有关

相关文章

网友评论

      本文标题:Intent.FLAG_ACTIVITY_NEW_TASK |

      本文链接:https://www.haomeiwen.com/subject/svdtektx.html