I created an android application with a logout option in onCreateOptionsMenu. The Logout works perfectly but when I press the back button again it takes me to t
onCreateOptionsMenu
For API 21 and up
finishAndRemoveTask()
You can call this to close the app completely. All activities will finish() and the app is removed from the task list.
finish()