How to Close/Exit Android Application Programmatically
Sometimes you need to close/exit your application without using hardware if any exception occurs. In this tutorial, you will learn to close/...
http://www.viralandroid.com/2016/01/how-to-closeexit-android-application.html
Sometimes you need to close/exit your application without using hardware if any exception occurs. In this tutorial, you will learn to close/exit your android application programmatically.
While closing your application when any exception occurs it is better to show an error message at first and exit your application.
Following code shows you to close/exit your running android application.
Related:
Hide and Show Android ActionBar in Any Activity
How to Convert Drawable to Bitmap in Android
How to Remove/Delete Android Project from Android Studio
Following is the content of java activity file and XML layout File.
This is XML content of android layout file where I have added a button and add onClick attribute.
res/layout/close_android_app.xml
src/ ExitAndroidAppProgrammatically.java
Now, run your How to Close/Exit Android Application Programmatically application and click the Click to Close/Exit App button, your application will be closed.
While closing your application when any exception occurs it is better to show an error message at first and exit your application.
Following code shows you to close/exit your running android application.
Related:
Hide and Show Android ActionBar in Any Activity
How to Convert Drawable to Bitmap in Android
How to Remove/Delete Android Project from Android Studio
Android Example: Close/Exit Android Application Programmatically
Following is the content of java activity file and XML layout File.
XML Layout File
This is XML content of android layout file where I have added a button and add onClick attribute.
res/layout/close_android_app.xml
Java Activity File
src/ ExitAndroidAppProgrammatically.java
Now, run your How to Close/Exit Android Application Programmatically application and click the Click to Close/Exit App button, your application will be closed.