Skip to content

Instantly share code, notes, and snippets.

@gavelez
Created October 29, 2020 14:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavelez/9a0743644d921d8fc9d14ba39cb3cbc4 to your computer and use it in GitHub Desktop.
Save gavelez/9a0743644d921d8fc9d14ba39cb3cbc4 to your computer and use it in GitHub Desktop.
Validate if a Fragment is active
public static boolean isSafeFragment( Fragment frag )
{
return !(frag.isRemoving() || frag.getActivity() == null || frag.isDetached() || !frag.isAdded() || frag.getView() == null );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment