I\'ve been working a lot with fragments lately and I was just curious as to what the best practice is for using a reference to a fragment\'s parent activity. Would it be bet
If you are in the fragment which is called from some activity, to get the reference to parent activity you can call it inside onViewCreated() or later hook methods of fragment directly by, it is just to make sure that parent activity is not null
getActivity()
If you want to really make sure you need to check first
if (getActivity() != null){ // then your logic with getActivity()}