Add onPause() to your activity and call finish() in your activity. Keep in mind that this will happen every pause, including dialogs, incoming calls, users who activate Notification . You might want to consider finish() in onStop() , which will at least solve the dialog problem.
Also, keep in mind that users may get confused when using your application, thinking that it crashed since it disappeared when they try to return to it.
source share