更改配置会杀死应用程序并重新启动它吗?

编程入门 行业动态 更新时间:2024-10-12 05:52:56
本文介绍了更改配置会杀死应用程序并重新启动它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在阅读本教程第6.1节.它说,更改应用程序的配置会导致应用程序重新启动吗?

I was reading This Tutorial section 6.1. And it says that, changing the configuration of an App causes the App to Restart?

我的问题是,该应用将在什么意义上重新启动?这是否意味着当配置更改时,将依次调用onStop()和onCreate()吗?但这仅在具有更高优先级的其他应用需要内存时发生!

My question is, in what sense the App would Restart? does it mean that when the configuration changes, onStop() then onCreate() will be called? But this only happens when another App with higher priority needs memory!

OR

从某种意义上说,将依次调用onStop()然后onRestart()然后onStart()?

In the sense that, the onStop() then onRestart() then onStart() will be called?

我创建了一个示例应用程序,仅包含onCreate()回调和Log语句,并且每次我重新定向设备时,Log语句显示@onCreate()都表示更改该应用程序.导致它被杀死并重新启动并再次调用onCreate()?

I created a sample App, with only onCreate() callback and with a Log statement, and every time I re-orient the device, the Log statement displays @onCreate() does it mean that changing the configuration of the App. causes it to be killed and restarted over and calls onCreate() again?

请尽可能澄清一下

推荐答案

该应用不会终止重新启动的应用.

The app is not killed an restarted.

但是,您的活动将被重新创建.

Your Activity will, however, be recreated.

如果您考虑旋转设备时如何更改活动"的布局,这很有道理.如果layout/文件夹中有纵向布局,而layout-land/文件夹中有横向布局,则Android将需要销毁Activity并使用新布局重新创建它.

If you think about how an Activity's layout can be changed when the device is rotated, this makes sense. If you have a portrait layout in your layout/ folder and and landscape layout in your layout-land/ folder, then Android will need to destroy the Activity and recreate it with the new layout.

更多推荐

更改配置会杀死应用程序并重新启动它吗?

本文发布于:2023-11-27 13:24:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638257.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重新启动   应用程序

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!