退出Android中的应用程序 [英] Quitting application in Android
问题描述
我想退出Android中的应用程序.只需点击退出"按钮,该按钮就会终止我的应用.
I want to quit application in Android. Just put a "quit" button, which kills my app.
我知道我不应该这样做.我知道这不是操作系统的哲学.
I know I shouldn't do this. I know that this is not the philosophy of the OS.
如果您知道该怎么做,请分享.
If you know how it can be done, pls share.
在应用程序中,我有很多打开的活动,因此"finish()"将无法完成工作.
In the app, I have many opened activities, so "finish()" will not do the job.
感谢您提前提供信息.丹尼尔(Danail)
Thank you for your information in advance. Danail
推荐答案
您的答案对我来说是Pentium10,但我还需要做一件事:
Your answer helped me, Pentium10, but I needed to do one more thing :
我必须使用以下命令清除(关闭)我以前的所有活动
I had to clear(close) all my previous activities with
意图i =新的意图();
Intent i = new Intent();
i.setClass(this,FirstActivity.class);
i.setClass(this, FirstActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(i);
startActivity(i);
这意味着:关闭在FirstActivity之后开始的每个活动.(换句话说,这将清除FirstActivity上方的活动堆栈).然后,我要做的就是完成FirstActivity.
This means: every activity, started after FirstActivity, is closed. (In other words, this cleans the activity stack above FirstActivity). Then all I have to do is finish my FirstActivity.
这篇关于退出Android中的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!