finish、onDestory、System.exit的区别
来源:互联网 发布:怎么加入农村淘宝网 编辑:程序博客网 时间:2024/05/20 16:39
Activity.finish()
Call this when your activity is done and should be closed.
在你的activity动作完成的时候,或者Activity需要关闭的时候,调用此方法。
当你调用此方法的时候,系统只是将最上面的Activity移出了栈,并没有及时的调用onDestory()
方法,其占用的资源也没有被及时释放。因为移出了栈,所以当你点击手机上面的“back”按键的时候,也不会再找到这个Activity。
Activity.onDestory()
the system is temporarily destroying this instance of the activity to save space. 系统销毁了这个Activity的实例在内存中占据的空间。
在Activity的生命周期中,onDestory()
方法是他生命的最后一步,资源空间等就被回收了。当重新进入此Activity的时候,必须重新创建,执行onCreate()
方法。
System.exit(0)
这玩意是退出整个应用程序的,是针对整个Application的。将整个进程直接KO掉。
finish函数仅仅把当前Activity退出了,但是并没有释放他的资源。安卓系统自己决定何时从内存中释放应用程序。当系统没有可用内存到时候,会按照优先级,释放部分应用。
总结
大多数时候,需要按照开发需求调用不同的方法
最后的最后,愿我们共同进步!
0 0
- finish、onDestory、System.exit的区别
- android中 finish()、onDestory()与system.exit(0)的区别
- activity的跳转--finish() onDestory() system.exit()
- Android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- Android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- Android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- Android finish onDestory system.exit(0)
- finish/onDestroy/System.exit()的区别
- Activity详解(生命周期,finish()、onDestory()和System.exit(0) )
- Activity.finish() 、Activity.onDestory() and System.exit(0)
- jvm的参数查询列表
- 求1000阶乘中最后0的个数
- SVM-7-SMO(序列最小优化算法)
- 技术网站
- SpringMvc+Mybatis整合hbase时出现的问题
- finish、onDestory、System.exit的区别
- eclipse设置jvm
- hive json数据生成和处理
- mipi 调试经验
- 管理对象图以避免内存泄露
- 队列之顺序队列与循环队列
- 自定义ViewGroup,流式布局FlowLayout
- 用FileSystem API来操作HDFS
- 指定存储位置/Bitmap内存溢出解决/解决Bitmap无法序列化问题/输入流转Bitmap