moveTaskToBack in onCreate causes activity to show briefly and then hide

怎甘沉沦 提交于 2019-12-06 18:49:26

Had the same problem. Solved by adding android:windowDisablePreview attribute in your theme.

For example, in your res/values/styles.xml:

<resources>

    <!-- Base application theme. -->
    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <!-- Customize your theme here. -->
        <item name="android:windowDisablePreview">true</item>
    </style>

</resources>

Not sure if there is any way to add it programatically though.

Had the same problem.
Solved it by starting a service which then opens the Activity when it's needed. This is the recommended way to do it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!