Paused 
谷歌官方的解释是:Another activity is in the foreground and has focus, but this one is still visible. That is, another activity is visible on top of this one and that activity is partially transparent or doesn’t cover the entire screen. A paused activity is completely alive (the Activity object is retained in memory, it maintains all state and member information, and remains attached to the window manager), but can be killed by the system in extremely low memory situations.

另外一个activity(BActivity)在前台显示并且获取了焦点,但是之前的activity(AActivity)还是可见的。即,BActivity在AActivity的上面并且BActivity是部分透明的或者不覆盖整个屏幕。一个处于paused状态的Activity 是完全活着的,(Activity对象保留在内存中,它保持着所有的状态和成员信息并且和windows Manager保持着相连接),但可以在低内存的时候被系统杀死。 
Stopped 
谷歌官方的解释是:The activity is completely obscured by another activity (the activity is now in the “background”). A stopped activity is also still alive (the Activity object is retained in memory, it maintains all state and member information, but is not attached to the window manager). However, it is no longer visible to the user and it can be killed by the system when memory is needed elsewhere.

一个activity(AActivity)完全被另一个Activity(BActivity)挡住(AActivity在后面)。一个处于Stopped状态的activity 也是任然活着的(Activity对象保留在内存中,它保持所有的状态和成员信息,但是和Stopped不同的一点就是没有和Windows Manager相连接),然而它不再对用户可见,它可以在任何需要内存的地方被杀死。

OnPause()

官方对OnPause()方法的解释如下: 
Called when the system is about to start resuming another activity. This method is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns. 
Followed either by onResume() if the activity returns back to the front, or by onStop() if it becomes invisible to the user.

当系统即将恢复另一个activity的时候,此方法通常用于提交一些未保存的持久性数据,停止动画和一些可能会消耗CPU的东西,它应该尽一切可能快的完成,因为接下来的Activity在OnPause()返回之前不会被恢复。 
接下来要么运行onResume()方法(如果Activity返回到前台),要么运行onStop()方法(如果Activity变得对用户不可见)。 
Called when the activity is no longer visible to the user. This may happen because it is being destroyed, or because another activity (either an existing one or a new one) has been resumed and is covering it. 
Followed either by onRestart() if the activity is coming back to interact with the user, or by onDestroy() if this activity is going away.

onStop()

Called when the activity is no longer visible to the user. This may happen because it is being destroyed, or because another activity (either an existing one or a new one) has been resumed and is covering it. 
Followed either by onRestart() if the activity is coming back to interact with the user, or by onDestroy() if this activity is going away.

当activity不再对用户可见时调用此方法,这方法可能被调用,因为它即将被销毁,或者因为另外一个Activity(可能是一个已经存在的Activity或者一个新的Activity)已经被恢复然后覆盖了这个activity。 
接下来如果这个activity 即将再次与用户交互(我觉得是再次对用户可见的意思),就会调用onRestart()方法,如果这个Activity即将死亡的话,就会调用onDestroy()方法。

上面是Activities中对OnPause()和onStop()的定义和解释。 
在Managing the activity lifeCycle中,对它们的描述是: 
Generally, you should not use onPause() to store user changes (such as personal information entered into a form) to permanent storage. The only time you should persist user changes to permanent storage within onPause() is when you’re certain users expect the changes to be auto-saved (such as when drafting an email). However, you should avoid performing CPU-intensive work during onPause(), such as writing to a database, because it can slow the visible transition to the next activity (you should instead perform heavy-load shutdown operations during onStop()). 
一般来说,我们不用该在onPause()中将例如一个表单内容保存到物理内存中,只有当你确认用户引起的变化是必须必须被自动保存的时候(例如起草一封电子邮件)。然而你应该避免在onPause()的时候做一些占用CPU很长的工作,比如写数据库,因为它会减缓下一个Activity出现的过程(意思就是要尽可能快地运行完onPause()),你应该在onStop的时候干这个事情。

源地址http://blog.csdn.net/rainbow88888/article/details/50927524

转载于:https://blog.51cto.com/scorpionspirit/1900343

Android onPause()和onStop()区别相关推荐

  1. Android Activity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?

    Android Activity为什么要细化出onCreate.onStart.onResume.onPause.onStop.onDesdroy这么多方法让应用去重载? 原创链接:http://bl ...

  2. android activity pause,关于android:onPause()和onStop()在Activity中

    我是Android开发的新手,但我仍然无法理解活动中的onPause()和onStop()方法. 在我的应用程序中,我有一个名为Counter的静态类,该类将变量的状态保存在应用程序的内存中.我的应用 ...

  3. Android @id和@+id区别

    Android中的组件需要用一个int类型的id属性值来表示.id属性只能接受资源类型的值,也就是必须以@开头的值,例如,@id/abc.@+id/xyz等.如果在@后面使用"+" ...

  4. 安卓activity生存周期的onCreate、onRestoreInstanceState、onRestart、onStart、onResume、onPause、onStop、onDestroy

    全栈工程师开发手册 (作者:栾鹏) 安卓教程全解 每一个Activity的状态是由它在Activity栈中所处的位置所决定的, Activity其是当前所有正在运行的Activity的后进先出的集合. ...

  5. android 上午零点格式,Android零点一度的区别——Matrix

    2013-07-07 导语:Matrix是android中对图像绘制的处理(旋转.放缩.平移等等),貌似书本翻页就是用这种方式处理的 正文: 1.基于坐标(px,py)旋转degrees度, post ...

  6. Android与IOS测试区别

    Android与IOS测试区别 Android与IOS测试区别 Android与IOS测试区别 Android开源,IOS非开源. 测试工具不同(由于Android开源,IOS非开源,Android自 ...

  7. Android SDK与JDK区别和联系

    Android SDK Android SDK(Soft Development Kit)全称为安卓软件开发工具包,***(通俗理解)***相当于安卓机器的操作系统,类似与windows操作系统,其也 ...

  8. 微信扫一扫 Android 与 IOS 小区别

    wx.scanQRCode({ needResult: 0, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果, scanType: ["qrCode","bar ...

  9. android onpause时动画出错,Android生命周期之onPauseonStop

    今天接到一个电话面试,就问了一个问题,说:你详细说一下生命周期中onPause. 这肯定是学习Android的第一课,但是面试官问我这个问题明显是问我深度而不是广度,我只是简单地回答了一句,是可见但不 ...

最新文章

  1. linux7提示软件安装源位置不对,详解 RHEL7.1 yum源配置与软件安装
  2. 图文并茂,详细讲解UML类图符号、各种关系说明以及举例
  3. python numpy加速 cupy
  4. Leetcode 963. 最小面积矩形 II 解题思路及C++实现
  5. html5水调歌头代码,张惠言的五首《水调歌头》
  6. Linux网络编程---详解TCP
  7. 计算机中丢失xapofx1 5.dll,xapofx1 5 dll丢失怎么办_系统提示xapofx1 5 dll丢失的解决方法...
  8. c++ mysql ctime_CTime::Format
  9. 永辉生活APP卖茅台只收款不发货,永辉超市回应...
  10. 30年前的中专相当于现在什么学历?比现在一本厉害吗?
  11. 北京自动驾驶路测名单更新:蔚来和Pony.ai也获准上路了
  12. Nodejs中的this详解
  13. bp神经网络预测模型优点,bp神经网络优化算法
  14. audio接线图解_图文:主板跳线(排线)连接技巧HD AUDIO连线接法
  15. 产品部和业务部门是什么关系
  16. 2.1 zio入门——把函数作用作为工作蓝图
  17. cpu空载50度,三代锐龙CPU待机50度降不下来?AMD的解决方案来了!
  18. python 操作键盘,鼠标 。我这个是自动企业微信加好友的,源码可以修改成别的。挺好使!
  19. 前端web:响应式Web开发优缺点总结
  20. 谷歌PR值停止更新的影响

热门文章

  1. 搭建web服务器,发布站点
  2. 深入理解HTTP Session
  3. 用init-connect+binlog实现用户操作追踪【转】
  4. Nginx防盗链详细设置
  5. 数据库授予用户增删改查的权限的语句_软件测试之浅谈数据库技术概述
  6. 半木夏低风险交易记录二
  7. Andorid SQLite数据库开发基础教程(3)
  8. Avahi DOS攻击broadcast-avahi-dos
  9. php拷贝mysql表_MySQL复制表数据或表结构到新表中
  10. dabs是什么意思_单词flounder是什么中文意思