FragmentActivity as a tab in TabHost
<p>I would like to get a sample code to display a new FragmentActivity that uses a TabHost in my main FragmentActivity. The FragmentActivity consists of five tabs and one of the tabs must show a new Activity having tabs.
My code:</p>

<pre><code>        TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() {

        @Override
        public void onTabChanged(String tabId) {




             fm =   getSupportFragmentManager();
             venueFragment = (FragmentVenue) fm.findFragmentByTag("venue");
             favoriteFragment = (FragmentFavorite) fm.findFragmentByTag("favorite");
             venueTrendingFragment = (FragmentVenueTrending) fm.findFragmentByTag("venuetrendingnow");
             searchFragment = (FragmentSearch) fm.findFragmentByTag("search");
             accountFragment = (FragmentAccount) fm.findFragmentByTag("account");



            android.support.v4.app.FragmentTransaction ft = fm.beginTransaction();

            /** Detaches the venueFragment if exists */
            if(venueFragment!=null)
                ft.detach(venueFragment);

            /** Detaches the favoriteFragment if exists */
            if(favoriteFragment!=null)
                ft.detach(favoriteFragment);

            /** Detaches the venueTrendingFragment if exists */
            if(venueTrendingFragment!=null)
                ft.detach(venueTrendingFragment);

            /** Detaches the searchFragment if exists */
            if(searchFragment!=null)
                ft.detach(searchFragment);

            if(accountFragment!=null)
                ft.detach(accountFragment);

            /** If current tab is venue */
            if(tabId.equalsIgnoreCase("venue")){                

                if(venueFragment==null){        
                    /** Create venueFragment and adding to fragment transaction */
                    ft.add(R.id.realtabcontent,new FragmentVenue(), "venue");                       
                }else{
                    /** Bring to the front, if already exists in the fragment transaction */
                    ft.attach(venueFragment);                       
                }

            }else if(tabId.equalsIgnoreCase("favorite")){   /** If current tab is favorite */

                if(favoriteFragment==null){
                    /** Create favoriteFragment and adding to fragment transaction */
                    ft.add(R.id.realtabcontent,new FragmentFavorite(), "favorite");                     
                }else{
                    /** Bring to the front, if already exists in the fragment transaction */
                    ft.attach(favoriteFragment);                        
                }
            }else if(tabId.equalsIgnoreCase("venuetrendingnow")){   /** If current tab is venueTrendingFragment */

                if(venueTrendingFragment==null){
                    /** Create venueTrendingFragment and adding to fragment transaction */
                    ft.add(R.id.realtabcontent,new FragmentVenueTrending(), "venuetrendingnow");                        
                }else{
                    /** Bring to the front, if already exists in the fragment transaction */
                    ft.attach(venueTrendingFragment);                       
                }
            }else if(tabId.equalsIgnoreCase("search")){ /** If current tab is searchFragment */

                if(searchFragment==null){

                    /** Create searchFragment and adding to fragment transaction */
                    //ft.add(R.id.realtabcontent,new FragmentSearch(MainActivity.this), "search");
                    //Intent intent = new Intent(this,SecondTabhost.class);
                    Intent intent = new Intent(MainActivity.this, SecondTabhost.class);
                    startActivity(intent); 
                }else{
                    /** Bring to the front, if already exists in the fragment transaction */
                    //ft.attach(searchFragment);    
                    Intent intent = new Intent(MainActivity.this, SecondTabhost.class);
                    startActivity(intent);
                }
            }else if(tabId.equalsIgnoreCase("account")){    /** If current tab is accountFragment */

                if(accountFragment==null){
                    /** Create accountFragment and adding to fragment transaction */
                    ft.add(R.id.realtabcontent,new FragmentAccount(), "account");                       
                }else{
                    /** Bring to the front, if already exists in the fragment transaction */
                    ft.attach(accountFragment);                     
                }
            }

            ft.commit();                
        }
    };
</code></pre>

<p>Inside else if(tabId.equalsIgnoreCase("search")) in the above code I used Intent to go to next activity so it delays to display next FragmentActivity having tabhost. I want to display the activity without any delay.</p>
