Android Tab Turn Back to ActivityGroup

504 views Asked by At

I'm using ActivityGroup for my tabs.

In my TabActivity onCreate

tabHost = getTabHost();
    TabHost.TabSpec tabSpec;
    Intent intent;

    intent = new Intent(MainActivity.this, FirstActivity.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    tabSpec = tabHost.newTabSpec("tab1");
    tabSpec.setContent(intent);
    tabHost.addTab(tabSpec);

And my FirstActivity extends ActivityGroup and after a button click I'm going to SecondActivity like that;

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                    View view = getLocalActivityManager().startActivity("xyz", intent).getDecorView();
                    setContentView(view);

And when I'm in the SecondActivity, after click the "tab1", I can not go to FirstActivity. How can I solve this problem?

1

There are 1 answers

2
Newts On BEST ANSWER

You have to start first activity by activity group like this

  Intent intent = new Intent(this,FirstActivity.class);
    startChildActivity("first", intent);

then create FirstActivity as simple activity and then start second activity.

And also try this link

http://developer.android.com/resources/tutorials/views/hello-tabwidget.html