Android 2.2 SDK Kill app completely

2019-08-29 02:38发布

问题:

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

回答1:

To do what you want, simply call System.exit(0). Is it highly recommended you do NOT do this though.



回答2:

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.



回答3:

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



标签: android sdk