Intent.FLAG_ACTIVITY_NEW_TASK |

2020-09-04  本文已影响0人  陈萍儿Candy
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
和预览窗口有关

上一篇 下一篇

猜你喜欢

热点阅读