更改配置会杀死应用程序并重新启动它吗? [英] Does changing the configuration Kill the App and Restart it?

查看:150
本文介绍了更改配置会杀死应用程序并重新启动它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读本教程第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.

这篇关于更改配置会杀死应用程序并重新启动它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆