I'm not using a ViewPager
, and the only places where I am calling any Fragment
transactions is on clicking buttons that live on a navbar in my activity's layout.
When I switch to fragments too quickly (like back and forth), I get this exception:
java.lang.IllegalStateException: No activity
It seems to be when I click to switch another Fragment
while the first one hasn't completely finished loading. I'm using a FragmentActivity
.
Can anyone shed some insight on this?
My code to switch Fragment
s:
fragmentManager.beginTransaction()
.replace(R.id.container, old,
fragment.getClass().getSimpleName())
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN).commit();
Edit: Taking out the transition solved the problem, but I'm wondering if there is a way to do this with transitions in place. My theory is that the transition delays the fragment lifecycle and causes activity to be null when another fragment transaction is initiated.