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
精彩评论