Android 2.2 SDK Kill app completely

2019-08-29 02:30发布

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

标签: android sdk
3条回答
劫难
2楼-- · 2019-08-29 02:44

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

查看更多
你好瞎i
3楼-- · 2019-08-29 02:44

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.

查看更多
▲ chillily
4楼-- · 2019-08-29 02:54

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

查看更多
登录 后发表回答