kalpana c
kalpana c

Reputation: 2739

Issue with onActivityResult in tab activity

I'm developing an application that uses tabHost. In that 5 tabs, Each and every single tab can open multiple activities. My problem is that in last tab (5th tab) I did the functionality of camera capture so it open camera and capture image but before call onActivityResult it call the first tab(1st tab) and after that call onActivityResult of last tab. But I do not know why this happens?

My code is here:

For create multiple activities I use this: http://ericharlow.blogspot.in/2010/09/experience-multiple-android-activities.html

TabPage:

public class TabPage extends TabActivity {

    Resources res;
    public static TabHost tabHost;
    TabSpec obj, obj1;
    Intent intent;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);     
        tabHost = getTabHost();
        res = getResources();

        obj1 = tabHost.newTabSpec("tab1");
        tabHost.addTab(obj1.setIndicator("",
                res.getDrawable(R.drawable.tab1)).setContent(
                new Intent(this, Act1.class)));
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        obj = tabHost.newTabSpec("tab2");
        tabHost.addTab(obj.setIndicator("",
                res.getDrawable(R.drawable.tab2)).setContent(
                new Intent(this, Act2.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        obj = tabHost.newTabSpec("tab3");
        tabHost.addTab(obj.setIndicator("",
                res.getDrawable(R.drawable.tab3)).setContent(
                new Intent(this, Act3.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        obj = tabHost.newTabSpec("tab4");
        tabHost.addTab(obj.setIndicator("",
                res.getDrawable(R.drawable.tab4)).setContent(
                new Intent(this, Act4.class)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));

        obj = tabHost.newTabSpec("tab5");
        tabHost.addTab(obj.setIndicator("",
                res.getDrawable(R.drawable.tab5)).setContent(
                new Intent(this, Act5.class)));

            tabHost.setCurrentTab(0);

    }

    public void switchTab(int tab) {
        tabHost.setCurrentTab(tab);
    }

}

Upvotes: 3

Views: 3816

Answers (1)

Related Questions