android使用finish()和System.exit()退出应用程序的理解

本文详细解释了Android应用如何在后台运行,并深入探讨了如何正确地让应用退出后台状态,避免误操作导致的应用无法正常退出的问题。通过分析finish()与System.exit(0)的区别,提供了一种理解Android应用生命周期管理的有效途径。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

this.finish() in Activity only stop and destroy this activity, application still staying background (check by hold HOME button)
I used:
System.exit(0);
but it still appear there!
That's how Android works. The user/developer is not given any way to actually exit the application. When you call 'finish', the application stack is just pushed to the background. It still exists in the memory. Android itself decides when to close the application(i.e. remove its instance from the memory) and generally this is done when your application becomes the oldest application which was not used for the longest time.

this.finish()主要是对Activity,当前的Activity结束了,但是整个Application还是在内存中运行,此时Application就成为了background进程,System.exit(0)是结束当前进程

转载于:https://www.cnblogs.com/kevin-wang/archive/2012/02/17/2355694.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值