如何杀死在Android的

问题描述:

进度

,当我试图退出,我运行下面的代码,但我不能杀的进展,如何杀死在Android的

所以如果我重新启动我的应用程序,另一个进步started.what事?

我退出代码:

Intent startMain = new Intent(Intent.ACTION_MAIN); 
    startMain.addCategory(Intent.CATEGORY_HOME); 
    startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    startActivity(startMain); 
    System.exit(0); 
    finish(); 
+0

为uploding你需要增加你的信誉得分是图像1现在...你需要为了获得使用此功能的特权,请在网站上注册至少10个声望的成员http://meta.stackexchange.com/questions/75491/how-to-upload-an-image-to-a-post – 2012-07-19 08:52:26

+0

这个活动是你的根源活动还是只活跃在堆栈中? – 2012-07-19 08:55:46

+1

http://*.com/questions/2092951/how-to-close-android-application – 2012-07-19 08:57:49

使用此代码来结束你的应用程序

finish(); 
     Intent intent = new Intent(Intent.ACTION_MAIN); 
     intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
     intent.addCategory(Intent.CATEGORY_HOME); 
     startActivity(intent); 
+1

非常感谢,它真的有效! – Stilo 2012-07-19 09:14:11

+0

为什么先调用finish()?在它开始另一项活动之前,这不会关闭活动吗? – wojciii 2012-07-19 09:21:13

+0

是的,它会关闭活动,然后开始一个新的活动,清除顶部的标志,活动堆栈将被清除,第二个标志确保主屏幕,这样所有进程将悄悄停止并且应用程序关闭 – vipin 2012-07-19 10:46:28