saravanan
saravanan

Reputation: 21

Can't exit an Android application

When I exit my android application it resumes to the previous screen. How can I exit the Android application properly?

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // TODO Auto-generated method stub
    switch(item.getItemId()) {
         case EXIT:
             try {
                 this.finish();
             } catch(Exception e) {
             }
             break;
      }
      return false;
 }

Upvotes: 1

Views: 5918

Answers (4)

Steve Sybesma
Steve Sybesma

Reputation: 1

If I don't exit my Android app such as myTuner, the radio station keeps playing...stopping it from playing is kind of ridiculous when exiting to give back the phone its memory makes every bit more sense. Whoever thought of allowing Android apps to just accumulate un-exited and slow down your phone made a huge mistake in my opinion.

It's how people want to user their phone that matters more than how someone else thinks they have to use it. I prefer freedom of choice for something that makes more sense. Make apps you can exit out of like other OSes allow for.

Upvotes: 0

Ndupza
Ndupza

Reputation: 780

//Put this in to exit an application. Not a window
System.Exit(0);

Upvotes: 0

brig
brig

Reputation: 3773

 this.finish();

will only finishes your current activity , that's the reason your resuming to previous screen.

In android you can't kill the application.

Still you want to kill your application , then kill your process ID.

Upvotes: 1

David Webb
David Webb

Reputation: 193696

The answer is that you shouldn't exit your Android application.

Have a look at this excellent answer for more information.

Upvotes: 5

Related Questions