In general, I would advise this because it violates UX. The user expects the back button to kill the entire window, especially since you are using tabhost. To the user, the entire group (tabs and all) is one action that he wants to exit when he presses the "Back" button.
If you still want to do this, refer to # onBackPressed () . It is called when activity detects a click on a button from the back. By default, the operation is performed, but you can do whatever you want. I advise caution and caution.
Here you can find inspiration.
James lim
source share