gpt4 book ai didi

android - 当后台 "sleeping"应用程序过多时,Android 操作系统会发生什么情况?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:33:07 26 4
gpt4 key购买 nike

我一直在读到 Android(与大多数移动操作系统一样)不会“退出”应用程序。

当我们按下后退按钮时,应用程序仍处于后台(类似于空闲状态)。

所以,我想知道,当后台运行的应用程序过多时,它会做什么?

最佳答案

来自 official Android developer guide :

The Android system tries to maintain an application process for as long as possible, but eventually it will need to remove old processes when memory runs low. To determine which processes to keep and which to kill, Android places each process into an "importance hierarchy" based on the components running in it and the state of those components. Processes with the lowest importance are eliminated first, then those with the next lowest, and so on.

从用户的角度来看,Android 设备的内存越大越好。为什么?未使用的应用程序处于“空闲”状态并占用设备的一部分 RAM。

每次您从零开始一个应用程序,即一个非空闲的应用程序,Android 的 CPU 将耗尽资源以使其恢复活力并进入内存。

当应用程序进入空闲模式并稍后返回 Activity 模式时,它不会占用那么多 CPU。如果我们不考虑 GPS、WI-FI 和蓝牙,CPU 使用是主要的电池消耗。

那么,这一切意味着什么呢?您希望经常使用的应用程序驻留在内存中,这样 CPU 就不会被占用太多。 Android 会根据优先级让它们保持 Activity 状态。

这就是为什么任务 killer 不是一个好主意的原因,这就是为什么它们在 Android 2.2 中不再起作用的原因,Froyo。

关于android - 当后台 "sleeping"应用程序过多时,Android 操作系统会发生什么情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4957558/

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