Calling getSupportFragmentManager() after getChildFragmentManager() causes IllegalStateException: Recursive entry to executePendingTransactions


I am using FrameLayout to show fragments

 <FrameLayout
        android:id="@+id/fragment_content"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@+id/bottom_layout"
        android:background="@android:color/white" >
    </FrameLayout>

and to open fragment i am using this

ft.add(R.id.fragment_content, frag);
ft.commit();
fm.beginTransaction();

One fragment contains map so i am using these lines in layout file

<fragment
        android:id="@+id/trafic_Alarm_main_mapView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.Utilities.MySupportMapFragment"
        android:layout_alignParentTop="true" />

and this is my Java code

try{
mMap=(MySupportMapFragment)TabsActivity.fm.findFragmentById(R.id.trafic_Alarm_main_mapView)).getMap();
}catch (Exception e){
mMap=((MySupportMapFragment)getChildFragmentManager().findFragmentById(R.id.trafic_Alarm_main_mapView)).getMap();
}

Now, if getChildFragmentManager() gets called and i switch to another fragment that uses getSupportFragmentManager to begin transaction causes crash . Provding logs

01-16 18:36:15.690    7294-7294/com.TrafikAlarm E/AndroidRuntime FATAL EXCEPTION: main
    Process: com.TrafikAlarm, PID: 7294
    java.lang.IllegalStateException: Recursive entry to executePendingTransactions
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1461)
            at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:454)
            at android.os.Handler.handleCallback(Handler.java:739)
            at android.os.Handler.dispatchMessage(Handler.java:95)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

I am using android studio and compiling these libraries ,

compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.android.support:appcompat-v7:21.0.3'

When i was using eclipse i did not need to use getChildFragmentManager and everything was working fine .

Thanks in advance.

Src : http://stackoverflow.com/questions/27985636/calling-getsupportfragmentmanager-after-getchildfragmentmanager-causes-illeg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s