I am getting an error message that activity has already been destroyed when FragmentManager is called. Is there a check that the FragmentManager can do before making it's transaction call or do I need to get the activity and check that it is not null or !activity.isFinishing() ? Are there any other checks I need to do? This is what I used to do but not sure this is still the way to do it? Just curious why fragment manager would not know about the state of the activity ... I need to cover both the case where the activity is about to be destroyed and where it has already been destroyed(). In either case I don't want to commit the transaction.
UPDATE: For API 17+ activity.isDestroyed() is available. For API < 17 still need to confirm that activity.isFinishing() will detect a destroyed activity or if there is another way to do this?
if ((activity != null) && !activity.isFinishing()) {
fm.FragmentTransaction fragmentTransaction =
fm.beginTransaction().replace(R.id.fragment_container, mFeedFragment).commitAllowingStatelessLoss();
}