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 6701579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:57:03+00:00 2026-05-26T06:57:03+00:00

In my app,i use a TabActivity with five tabs,each tab contain a ActvityGroup,each ActivityGroup

  • 0

In my app,i use a TabActivity with five tabs,each tab contain a ActvityGroup,each ActivityGroup manage more than one Activity.one of ActivtyGroups have two Activies:A and B, when click a button in A,it jump to B.when return to A,i want to display some changed data in B.what i meet is:

first, if i start B and some widget in B get focus,when click back button,app exit directly.i debug it and find when finish B it finish the app at the same time.second,if i start B and none of any widget get focus,when click back button,onKeyDown() in B does not work.

Here is my activitygroup,i ues viewanimator as container:

public class Group extends ActivityGroup 
{

    private Stack<String>aString;               
private LocalActivityManager manager;
private ViewAnimator animator;
private int ID;                              

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.group_products);

    aString = new Stack<String>();
    animator = (ViewAnimator) findViewById(R.id.pro_va_animator);
    manager = getLocalActivityManager();

    Intent intent = new Intent(this,Products_Category.class);
    startActivity(intent);
}

@Override
public void startActivity(Intent intent) 
{
    String id = "id" + ID++;
    aString.push(id);

    View view = manager.startActivity(id, intent).getDecorView();
    animator.addView(view);
    animator.setDisplayedChild(aString.size() - 1);
}

@Override
public void startActivityForResult(Intent intent,int requestCode)
{
    String id = "id" + ID++;
    aString.push(id);
    View view = manager.startActivity(id, intent).getDecorView();
    animator.addView(view);
    animator.setDisplayedChild(aString.size() - 1);
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) 
{
    if (keyCode == KeyEvent.KEYCODE_BACK) 
    {
        int size = aString.size();
        if (size > 0) 
        {
            String topId = aString.pop();
            View view = manager.destroyActivity(topId, true).getDecorView();
            animator.removeView(view);
            if (size > 1) 
            {
                return true;
            }
        }
    }
    return super.onKeyDown(keyCode, event);
}

@Override
protected void onActivityResult(int requestCode,int resultCode,Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);

    A subActivity=(A)(manager.getCurrentActivity());
    A.handleActivityResult(requestCode, resultCode, data);
    break;

}
}

In class B,i rewrite onKeyDown() to add some changed data in bundle:

@Override
public boolean onKeyDown(int keyCode,KeyEvent event)
{
    if(keyCode==KeyEvent.KEYCODE_BACK)
    {
        Log.e("prodcuts_3","inner");
        Bundle bundle=new Bundle();
        bundle.putString("name",name);
        bundle.putString("price",price);
        bundle.putString("quantity",quantity);

        this.setResult(RESULT_CANCELED,this.getIntent().putExtras(bundle));
        this.finish();
        return this.getParent().onKeyDown(keyCode, event);
    }
    return super.onKeyDown(keyCode, event);
}

in class A:

public void handleActivityResult(int requestCode,int resultCode,Intent data)
{
    if(resultCode==RESULT_CANCELED)
    {
        String price=data.getExtras().getString("price");
               ......
    }
}

thank you guys in advances!!

  • 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-26T06:57:04+00:00Added an answer on May 26, 2026 at 6:57 am

    add the following to your class which is called from class which extends TabGroupActivity

    @Override
        public void onBackPressed() {
           return;
        } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just wondering could ipod app use more cpu than the 600mhz (3rd
I have a TabActivity where each tab has ActivityGroup. On the home ActivityChild of
I would like to use tabs in my Android application and since TabActivity is
Have another issue here. Our app starts out with a tab activity. But, before
I am trying to use a main,java to initiate 3 tabs, and have each
My Android app, which uses a TabActivity to display its contents, has 4 tabs
The type TabActivity is deprecated? I am making the Tabs of app following tutorial
I am working on the Andriod Tab Layout App to get use to the
I'm trying to implement tabs for navigation in an Android app. Since TabActivity and
My Android app is created with a tab bar and the root activity is

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.