开发者

How to exit or quit android application?

开发者 https://www.devze.com 2023-02-21 12:39 出处:网络
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?

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

精彩评论

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