-2

I tried

public void onClick(View v) {
                        // TODO Auto-generated method stub
                        finish();
                        System.exit(0);
                    }

in an button onClick listener but it only kills the current activity..I want to be able to exit from the application.

Amel Jose
  • 873
  • 2
  • 9
  • 22

2 Answers2

1

Have a look at this:

Is quitting an application frowned upon?

Android doesn't really want you to quit the application, but here's how you would do it:

The short answer is, if you want to exit your application, you've got to keep track of all activities in your stack and finish() ALL of them when the user wants to exit (and no, there is no way to iterate through the Activity stack, so you have to manage all of this yourself).

Community
  • 1
  • 1
Alex W
  • 37,233
  • 13
  • 109
  • 109
0

The Android system takes care of this. You have no way to do it without causing state problems in the DVM. You'll have to find another way to accomplish whatever it is you are trying to achieve by completely killing the application.

Swifty McSwifterton
  • 2,637
  • 1
  • 30
  • 37