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

查看:31
本文介绍了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 工作原理?据我了解,Activity 的 LifeCycle 已完成.

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天全站免登陆