Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6183325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:20:47+00:00 2026-05-24T01:20:47+00:00

I have Main Activity. That has 4 tabs ( TabHost ). I have overridden

  • 0

I have Main Activity. That has 4 tabs (TabHost). I have overridden onBackPress() in MainActvity, as well as all four activities. This button show user a dialog box and for conformation of Exit
When app start. It show first tab. Then if I press back it works fine.

But if I go for next 3 tab and then press back, the app stop. OnDestroy() of Main is called. But there is not dialogue for the user.Even noting is print in log cat. That I have written in onBackPressed() method From and of 5 activities including MainActivity.

I have also try onKeyDown() for back key, but the result is same. Why is that the case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:20:48+00:00Added an answer on May 24, 2026 at 1:20 am

    I come to know it was difficult to open new activity inside the previous tabs when I am using TabHost. I google it and found GroupActivity is the best solution for this problem.
    GroupActvity Example
    But GroupActivity have the same problem when open new activity in the previous tab. the back button not work properly for new activity. After search I found that was due to the focus was alwasys on parent activity. I have to make

    setFocusable(true);
    requestFocus();

    on my new activity component to gain focus.

    I am now using GroupActivity for customizing Tabbar and activities.As I ma also maintaining stack of activity ids in parent activity so that I can pop out the recent activity when user press back button.

    else if you are NOT going to implement Activity focus then you should maintain stack in parent and when press the back button it will initiate parent onBackPressed(); and you can call the child onBackPressed() functionality as discussed in the link.

    onBackPressed() not working inside ActivityGroup

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app which has a main activity that calls other activities on
So I have my main activity that has some views and I have an
I have an app that has a list as its main activity and then
I have three tabs that each has its own Activity. The tabs are as
I have an app that goes between many different activities. One activity, my main
So, I have written an app that has a Main activity (A), and various
This has been killing me for two days now. I have a main Activity
This has been killing me for two days now. I have a main Activity
I have a custom TabHost that adds tabs like this private void setTab(View view,
I have an Activity ( Main ) which shows tabs like this: private void

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.