开发者

How to exit or quit android application?

I have created an sample application for android and tested it in my htc android mobile. I 开发者_运维百科want to know how to exit the application? can anyone give me sample code? thank you.


public void onClick(View v) {
    finish();
}


You can exit your current activity by calling the finish() method. If you also want to stop services you created you can call stopService(Intent i)

http://developer.android.com/reference/android/app/Activity.html#finish() http://developer.android.com/reference/android/content/ContextWrapper.html#stopService(android.content.Intent)


You can also override the finish() method and stop services, clean memoory...


System.Exit(0);

//Use that to exit the entire application. not just an Activity

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜