1

when I tried to exit, I run the code below, but I can't kill the progress,

so if I restart my App, another progress started.what's the matter?

my exit code:

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();
Isuru
  • 30,617
  • 60
  • 187
  • 303
Stilo
  • 23
  • 2
  • for uploding the image you need to increase your reputation score which is 1 right now... you need to be registered member in the site with at least 10 reputation in order to gain the privilege to use this feature http://meta.stackexchange.com/questions/75491/how-to-upload-an-image-to-a-post – Dheeresh Singh Jul 19 '12 at 08:52
  • is this activity is your root activity or only activity in stack currenly? – Dheeresh Singh Jul 19 '12 at 08:55
  • 1
    http://stackoverflow.com/questions/2092951/how-to-close-android-application – Dheeresh Singh Jul 19 '12 at 08:57
  • btw, you can upload images using http://imgur.com/ and share the link here, till you are allowed to upload images in SO – sunil Jul 19 '12 at 08:58
  • yes,it's my root activity,I can finish it but when I restart it, I can see another progress in DDMS,the original still exists. – Stilo Jul 19 '12 at 08:59

1 Answers1

0

use this code to end your application

 finish();
        Intent intent = new Intent(Intent.ACTION_MAIN); 
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
        intent.addCategory(Intent.CATEGORY_HOME); 
        startActivity(intent);
vipin
  • 2,851
  • 4
  • 18
  • 32
  • Why call finish() first? Will that not close the activity before it can start another one? – wojciii Jul 19 '12 at 09:21
  • yes it will close activity and then start a new activity with flag of clear top by which the activity stack will get cleared and the second flag ensure the home screen so all the process will quietly get stopped and application get closed – vipin Jul 19 '12 at 10:46