Now I noticed the commit title and understand that indeed you suspect that the activity is null.  But this fix doesn't seem to be enough, because there are other uses of getActivity().

I think ensuring that those uses are only when the fragment is resumed would be safest.