当我的应用程序“在顶部”运行时锁定屏幕时,系统几乎立即调用 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/