【趣读官方文档】1.管家的抉择 (Android进程生命周期)
前言:
进程生命周期 ,又名 你丑你先死
Process Lifecycle
The Android system attempts to keep application process around for as long as possible, but eventually will need to remove old processes when memory runs low. As described in Activity Lifecycle, the decision about which process to remove is intimately tied to the state of the user's interaction with it. In general, there are four states a process can be in based on the activities running in it, listed here in order of importance. The system will kill less important processes (the last ones) before it resorts to killing more important processes (the first ones).
The foreground activity (the activity at the top of the screen that the user is currently interacting with) is considered the most important. Its process will only be killed as a last resort, if it uses more memory than is available on the device. Generally at this point the device has reached a memory paging state, so this is required in order to keep the user interface responsive.
A visible activity (an activity that is visible to the user but not in the foreground, such as one sitting behind a foreground dialog) is considered extremely important and will not be killed unless that is required to keep the foreground activity running.
A background activity (an activity that is not visible to the user and has been paused) is no longer critical, so the system may safely kill its process to reclaim memory for other foreground or visible processes. If its process needs to be killed, when the user navigates back to the activity (making it visible on the screen again), its
onCreate(Bundle)
method will be called with the savedInstanceState it had previously supplied inonSaveInstanceState(Bundle)
so that it can restart itself in the same state as the user last left it.An empty process is one hosting no activities or other application components (such as
Service
orBroadcastReceiver
classes). These are killed very quickly by the system as memory becomes low. For this reason, any background operation you do outside of an activity must be executed in the context of an activity BroadcastReceiver or Service to ensure that the system knows it needs to keep your process around.
Sometimes an Activity may need to do a long-running operation that exists independently of the activity lifecycle itself. An example may be a camera application that allows you to upload a picture to a web site. The upload may take a long time, and the application should allow the user to leave the application while it is executing. To accomplish this, your Activity should start a Service
in which the upload takes place. This allows the system to properly prioritize your process (considering it to be more important than other non-visible applications) for the duration of the upload, independent of whether the original activity is paused, stopped, or finished.
【趣读官方文档】1.管家的抉择 (Android进程生命周期)相关推荐
- 【读官方文档,学原味技术】SpringBoot-Staters和自定义Starter
spring-boot-reference 如果不想阅读英文原文,你可以直接读本文的[TS]标注参考翻译内容.由于本人水平有限,如有理解错误,烦请指正,互相交流. Lire les documents ...
- android mvvm官方文档,MVVM: 这是一个android MVVM 框架,基于谷歌dataBinding技术实现
MVVM 这是一个android MVVM 框架,基于谷歌dataBinding技术实现.dataBinding 实现的 V 和 VM的关联:使用IOC架构实现了 M 和 V的关联. 框架具有以下功能 ...
- Poco 库开发-教你如何读Poco的官方文档
引言 在使用任何一种框架开发的时候,都不免要阅读官方的文档. 下面就讲述如何来读Poco库的官方文档 Poco库 在我们下载好Poco 后,会有两个文件夹,一个是放文档的doc,另外一个就是代码了,这 ...
- oracle12c官方文档中文版_三分钟让你真正读懂oracle12c 中cdb pdb概念及原理
Oracle 12C引入了CDB与PDB的新特性,在ORACLE 12C数据库引入的多租用户环境(Multitenant Environment)中,允许一个数据库容器(CDB)承载多个可插拔数据库( ...
- 使用cephadm部署单节点ceph集群,后期可扩容(基于官方文档,靠谱,读起来舒服)
目录 ceph各种部署工具比较(来自官方文档的翻译,靠谱!) 材料准备 cephadm使用条件 服务器有外网访问能力 服务器没有外网访问能力 安装cephadm cephadm的功能 两种安装方式 基 ...
- OpenCV-Python官方文档学习笔记(上)
整理自OpenCV-Python官方文档 一. OpenCV-Python Tutorials 1 安装及验证 2 图片读写,展示 3 视频读写,展示 4 绘图功能(绘制几何形状:线.圆.椭圆.矩形. ...
- Swift 4官方文档中文版 The Basic(上)
Swift学习交流群: 313838956 本群由Guards翻译组创建并维护, 志于给认真想学习Swift的同学打造一个良好的交流圈子. 该文章翻译自Apple官方文档: The Swift 4 P ...
- spark之4:基础指南(源自官方文档)
spark之4:基础指南(源自官方文档) @(SPARK)[spark, 大数据] spark之4基础指南源自官方文档 一简介 二接入Spark 三初始化Spark 一使用Shell 四弹性分布式数据 ...
- dubbo官方文档_不可忽视的Dubbo线程池
问题描述 线上突然出现Dubbo超时调用,时间刚好为Consumer端设置的超时时间. 有好几个不同的接口都报超时了 第1次调用超时,第2次(或第3次)重试调用非常快(正常水平) Dubbo调用超时的 ...
- Qt官方文档阅读笔记-对官方Star Delegate Example实例的解析
对应的博文为: 目录 Star Delegate Example StarDelegate Class Definition StarDelegate Class Implementation Sta ...
最新文章
- SAP MM ME21N 创建委外采购PO报错 - Not possible to determine any components - 之对策
- 基于ESP32的智能车竞赛新版裁判系统的软件功能要求与实现
- 分享个人预算系统源码(含说明文档)
- You must provide a username via either --os-username or env[OS_USERNAME]
- 大话设计模式笔记 享元模式
- python3.4学习笔记(八) Python第三方库安装与使用,包管理工具解惑
- 织梦dedecms响应式自媒体图片新闻资讯网站模板
- Jsoup实现java模拟登陆
- 硬盘格式化了的数据找到方案
- error: Setup script exited with error: Unable to find vcvarsall.bat
- 小程序消息订阅发送功能教程
- 计算机文件夹加密文件,电脑文件夹怎么加密,制作隐私的加密文件夹软件
- java 实体类校验_实体类的验证
- Java面试手册——高频问题总结(二)
- “跨次元”检测模型hold住各种画风,真人赛博,在线Demo可玩
- 详解GMT CST UTC DST PDT PST几个时间概念
- 获取手机电池百分比和电池容量方法
- 2019读过的好书推荐
- matlab likelihood,Matlab做空间面板模型log-likelihood为NAN怎么办
- 【MacOS】虚拟机Vmware安装MacOS