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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:31:50+00:00 2026-06-18T16:31:50+00:00

I am using following code to get data from internet and open it. It

  • 0

I am using following code to get data from internet and open it. It works pretty fine but gives error if i change the tab and go back to old tab. E.g if at start i am tab 1 and then go to tab2 works good but if i go back to tab 1 it gives error

public class MainMenu extends FragmentActivity 
{
    private TabHost tHost;

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
         this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,  
                     WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.main_menu);

        tHost = (TabHost) findViewById(android.R.id.tabhost);
        tHost.setup();

        /** Defining Tab Change Listener event. This is invoked when tab is changed */
        TabHost.OnTabChangeListener tabChangeListener = new TabHost.OnTabChangeListener() 
        {
            @Override
            public void onTabChanged(String tabId) 
            {
                FragmentManager fm =   getSupportFragmentManager();
                PrayerTimes prayerFragment = (PrayerTimes) fm.findFragmentByTag("prayerTimes");
                CompassActivity qiblaFragment = (CompassActivity) fm.findFragmentByTag("qibla");
                Settings settingFragment = (Settings) fm.findFragmentByTag("settings");


                FragmentTransaction ft = fm.beginTransaction();

                /** Detaches the androidfragment if exists */
                if(prayerFragment!=null)
                    ft.detach(prayerFragment);
                if(qiblaFragment!=null)
                    ft.detach(qiblaFragment);
                if(settingFragment!=null)
                    ft.detach(qiblaFragment);

                /** If current tab is android */
                if(tabId.equals("prayerTimes"))
                { 
                    if(prayerFragment == null)
                    {
                        /** Create AndroidFragment and adding to fragmenttransaction */
                        ft.add(R.id.realtabcontent,new PrayerTimes(), "prayerTimes");
                    }
                    else
                    {
                        /** Bring to the front, if already exists in the fragmenttransaction */
                        ft.attach(prayerFragment);
                    }

                }
                else if (tabId.equals("qibla"))
                {
                    if( qiblaFragment == null)
                    {
                        /** Create AppleFragment and adding to fragmenttransaction */
                        ft.add(R.id.realtabcontent,new CompassActivity(), "qibla");
                     }
                    else
                    {
                        /** Bring to the front, if already exists in the fragmenttransaction */
                        ft.attach(qiblaFragment);
                    }
                }
                else if(tabId.equals("settings"))
                {
                    if( settingFragment == null)
                    {
                        /** Create AppleFragment and adding to fragmenttransaction */
                        ft.add(R.id.realtabcontent,new Settings(), "settings");
                     }
                    else
                    {
                        /** Bring to the front, if already exists in the fragmenttransaction */
                        ft.attach(settingFragment);
                    }                   
                }
                ft.commit();
            }
        };

        /** Setting tabchangelistener for the tab */
        tHost.setOnTabChangedListener(tabChangeListener);

        /** Defining tab builder for Andriod tab */
        TabHost.TabSpec tSpecPrayer = tHost.newTabSpec("prayerTimes");
        tSpecPrayer.setIndicator("Prayer Times");
        tSpecPrayer.setContent(new MyTabContent(getBaseContext()));
        tHost.addTab(tSpecPrayer);

        /** Defining tab builder for Apple tab */
        TabHost.TabSpec tSpecQibla = tHost.newTabSpec("qibla");
        tSpecQibla.setIndicator("Qibla");
        tSpecQibla.setContent(new MyTabContent(getBaseContext()));
        tHost.addTab(tSpecQibla);

        TabHost.TabSpec tSpecSettings = tHost.newTabSpec("settings");
        tSpecSettings.setIndicator("Settings");
        tSpecSettings.setContent(new MyTabContent(getBaseContext()));
        tHost.addTab(tSpecSettings); 
    }
}

error is

2-11 12:21:28.245: E/AndroidRuntime(992): FATAL EXCEPTION: main
02-11 12:21:28.245: E/AndroidRuntime(992): java.lang.IllegalStateException: Recursive entry to executePendingTransactions
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:461)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.view.ViewPager.populate(ViewPager.java:1012)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:523)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.view.ViewPager.setCurrentItemInternal(ViewPager.java:495)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.view.ViewPager.onRestoreInstanceState(ViewPager.java:1221)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.view.View.dispatchRestoreInstanceState(View.java:12088)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2582)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:2588)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.view.View.restoreHierarchyState(View.java:12066)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.Fragment.restoreViewState(Fragment.java:417)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:933)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentManagerImpl.attachFragment(FragmentManager.java:1264)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:672)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1444)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:429)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.os.Handler.handleCallback(Handler.java:725)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.os.Handler.dispatchMessage(Handler.java:92)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.os.Looper.loop(Looper.java:137)
02-11 12:21:28.245: E/AndroidRuntime(992):  at android.app.ActivityThread.main(ActivityThread.java:5039)
02-11 12:21:28.245: E/AndroidRuntime(992):  at java.lang.reflect.Method.invokeNative(Native Method)
02-11 12:21:28.245: E/AndroidRuntime(992):  at java.lang.reflect.Method.invoke(Method.java:511)
02-11 12:21:28.245: E/AndroidRuntime(992):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-11 12:21:28.245: E/AndroidRuntime(992):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-11 12:21:28.245: E/AndroidRuntime(992):  at dalvik.system.NativeStart.main(Native Method)
  • 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-06-18T16:31:51+00:00Added an answer on June 18, 2026 at 4:31 pm

    The problem is that you are not allowed to create one fragment within another one. This causes the error. Luckily, with the latest update this now is possible and allowed.
    You find further information on how to do this on the Android documentation. Consider using the Android-Support library.

    http://developer.android.com/about/versions/jelly-bean.html#42-ui-tools

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

Sidebar

Related Questions

I am using the following code to get an XML data from a website
I am using the following code to get data from the database( from cs
I'm using following code but cannot return data from MySQL. This is the output:
I am using the following code to get data from $_REQUEST in php: for($i=0;$i<intval($q);$i++)
I am using the following Code, to get data from the Database in phpmyadmin,
I am using following code to get data from the Server and if the
I am using following code to get data from database and load to picture
I'm using the following code to get some data from an external website. <script
I am using the following code do get all data records from a MS
I'm trying to get JSON data from facebook using the following code: var getFriends

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.