Before API 23 I used Fragment's onAttach methods to get my listener instance, then the reference is cleaned inside onDetach. ex:
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mListener = null;
    try {
        mListener = (SellFragmentListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString()
                + " must implement SellFragmentListener");
    }
}
@Override
public void onDetach() {
    super.onDetach();
    mListener = null;
}
Is it safe to do the same check inside onAttach(Context context) or is there a better way to get the holder activity instance?
 
     
     
     
     
     
     
     
     
     
    