How can I kill an app completely from code?
I know it's possible, because when you click the exit button from Angry Birds, and then check the android task killer thing, it's gone.. but I can't get my own app to do that =/ It still hangs around and preserve's it's last state..which I don't want
I have tried this with no success:
@Override
public void onBackPressed()
{
// do something on back.
this.finish();
return;
}
Thanks for any help on this
To do what you want, simply call System.exit(0). Is it highly recommended you do NOT do this though.
FYI the finish code does not delete the object itself. It just gets run when cleanup of the object is required just before deletion. Logically Deletion => Call finish() and therefore the opposite is not required to be true (and in this case is not).
I suspect that what you are looking for should actually be specified in the android manifest and it is probably the android:noHist option.
You cannot kill your app completely in a legitimate way, there are some hacks for that, but basically no. Android will decide when to kill your app.
I think this link will help you do the most and get you what you want, but this will not kill your app: http://smartandroidians.blogspot.com/2010/01/exiting-android-application.html