Possible Duplicate:
android - exit application code
I'm a beginner in android, I'm practicing a Project that have a 2 labels and 1 exit button. But when I run this project in android phone the exit button is not working, it won't exit at all.
How can I make exit button work?
try this for close app
Don't ever put an Exit button on an Android app. Let the OS decide when to kill your Activity. Learn about the Android Activity lifecycle and implement any necessary callbacks.
You cannot exit your application. Using
android.finish()
won't exit the application, it just kills the activity. It's used when we don't want to see the previous activity on back button click. The application automatically exits when you switch off the device. The Android architecture does not support exiting the app. If you want, you can forcefully exit the app, but that's not considered good practice.finish()
- Call this when your activity is done and should be closed. TheActivityResult
is propagated back to whoever launched you viaonActivityResult()
.i try this
Below used main.xml file
and text.java file is below