android finish()方法不会从内存中清除应用 [英] android finish() method doesn't clear app from memory

查看:277
本文介绍了android finish()方法不会从内存中清除应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个活动,我调用了finish()方法,但该活动未从内存中清除.

I have an activity and I call the finish() method and the activity is not cleared from memory.

在调用finish()之后,我看到onDestroy()方法已成功执行(并且清除了所有变量和其中的内容).

After calling finish() , I see that the method onDestroy() is executed successfully (and I clear all my variables and stuff in there).

应该从内存中清除它还是android如何工作?据我了解,该活动的生命周期已完成.

Should it be cleared from memory or its how android works? As I understand the LifeCycle of the Activity is finished.

如果将应用程序保留在内存中,以便在用户第二次使用该应用程序时运行得更快,那么我可以在内存中保留哪些对象以供重用?如果我理解正确,我想清除onDestroy上的所有内容.

And if it keeps the app in memory so it runs faster the 2nd time the user uses it, what kind of objects can I leave in memory to reuse? If I understand correctly, I am suppose to clear everything on onDestroy.

推荐答案

Android会保留进程,以防用户想要重新启动应用程序,这可以加快启动阶段.该进程将不做任何事情,并且如果需要回收内存,则该进程将被终止.不用担心:)

Android keeps processes around in case the user wants to restart the app, this makes the startup phase faster. The process will not be doing anything and if memory needs to be reclaimed, the process will be killed. Don't worry about it :)

这篇关于android finish()方法不会从内存中清除应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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