android - Intent.FLAG_ACTIVITY_NEW_TASK | 如何避免黑屏Intent.FLAG_ACTIVITY_CLEAR_TASK 设置了吗?

标签 android android-intent

在我的 android 应用程序中,我需要使用 Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK设置我的 Intent 标志。我可以删除我以前的所有 Activities并开始一个新的 Activity以这种方式。这是我的代码如下:

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

但是,当我使用上面的代码时,我发现黑屏闪烁。如果我不使用 Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK 设置意向标志,黑屏的闪烁将消失。我的问题是:Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK时我该怎么做才能避免黑屏?设置好了吗?

在我写下这个问题之前,我发现有人有类似的问题。这是link但是,这个问题的答案不能解决我的问题。所以我再问这个问题。我希望有人能帮助我。谢谢。

最佳答案

您看到的这个初始屏幕称为“预览”屏幕。您可以通过在主题中声明来完全禁用它:

android:windowDisablePreview

<style name="Theme.MyTheme" parent="android:style/Theme.Holo">
    <!-- This disables the black preview screen -->
    <item name="android:windowDisablePreview">true</item>
</style>

关于android - Intent.FLAG_ACTIVITY_NEW_TASK | 如何避免黑屏Intent.FLAG_ACTIVITY_CLEAR_TASK 设置了吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31264157/

相关文章:

android - 奇怪 - Android IntentService 杀死了我应用程序的其余部分,但继续自行运行

android - React Native 深度链接和 android :launchMode problem

android - 安卓手机与智能电视(LG、Sony)收发数据支持DIAL

android - 无法使用改造库获取数据

android - java.lang.OutOfMemory错误: bitmap size exceeds VM budget - Android

Android 可扩展 ListView - onClickListener 用于具有持久状态的子项中的按钮

java - Android-使用 Intent 通过按钮单击将值发送到另一个 Activity 的 getStringExtra 的空指针异常

android - 通过数据链接打开 MvvmCross 应用程序

java - Android rom文件结构及调试

android - 如何将我的 Activity 发送到后台并恢复?