锁屏后调用Android onCreate

标签 android locking lifecycle android-lifecycle oncreate

当我的应用程序“在顶部”运行时锁定屏幕时,系统几乎立即调用 onCreate(屏幕仍然是黑色的)。这种破坏性行为的原因可能是什么?

最佳答案

对我来说

android:configChanges="orientation"

但这没有帮助,因为我的 Activity 是全屏的,所以我添加了

android:configChanges="keyboardHidden|orientation|screenSize"

在 Activity 标签中

Handling the Configuration Change Yourself 中所述

If your application doesn't need to update resources during a specific configuration change and you have a performance limitation that requires you to avoid the activity restart, then you can declare that your activity handles the configuration change itself, which prevents the system from restarting your activity.

关于锁屏后调用Android onCreate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16320040/

相关文章:

android - 在 build.gradle 文件中添加 buildFeatures 时出错

Android Activity ,finish() 会杀死我的倒计时线程吗?

java - 使用 Java 的卷影复制

lifecycle - 对于Storm Spouts,何时调用declareOutputFields()?

timer - 如何创建基于时间的 Flutter 应用程序?

android - RecyclerView 滚动到顶部,AsyncListDiffer 不起作用

java - 大负载 OkHTTP 上的流意外结束

android - 为启用了文本缩放的智能手机调整文本大小

c# - 使用悲观锁定将项目添加到 Microsoft.ApplicationServer.Caching.DataCache?

java - 锁.tryLock() : Thread performing different tasks?