gpt4 book ai didi

android - 为什么当用户在纵向和横向模式之间切换时,系统会销毁并重新启动一个 Activity?

转载 作者:搜寻专家 更新时间:2023-11-01 08:09:53 25 4
gpt4 key购买 nike

正如我们所知,当用户在纵向和横向模式之间切换时,android 会销毁并重新启动一个 Activity,我们可以通过覆盖 onConfigurationChanged() 回调来阻止这种情况。谁能向我解释一下系统销毁和启动 Activity 的实际需要是什么?如果我重写 onConfigurationChanged() 会有任何副作用吗?

最佳答案

While this behavior is really powerful, since your application adapts automatically to the device's configuration at runtime, it is sometimes confusing for new Android developers who wonder why their activity is destroyed and recreated. Facing this "issue," some developers choose to handle configuration changes themselves which is, in my opinion, a short-term solution that will complicate their life when other devices come out or when the application becomes more complex. The automatic resource handling is a very efficient and easy way to adapt your application's user interface to various devices and devices configurations. It sometimes comes at a price though.

引用:http://android-developers.blogspot.com/2009/02/faster-screen-orientation-change.html

关于android - 为什么当用户在纵向和横向模式之间切换时,系统会销毁并重新启动一个 Activity?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10834560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com