I have tried the following code in my back button but it opens the beginning activity again.
android.os.Process.killProcess(android.os.Process.myPid());
I have tried the following code in my back button but it opens the beginning activity again.
android.os.Process.killProcess(android.os.Process.myPid());
As per android guidelines, you should not kill the application. You have to use finish()
in each activity lifecycle to safely return to your initial activity and then exit the application.
If you want to exit the app in onBackPressed
event on your initial activity, just calling finish()
will do the job.
If service, stopSelf()
.
Try this. It will kill your application. All your services/receivers, Thread everything would be stopped.
public void onBackPressed() {
System.exit(0);
}
You cannot kill your application. The Android SDK does not allow this.