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 onAtt
I have faced the same situation. I have gone through various posts and finally implemented my code in onCreate() block of fragment.Till now i haven't faced any issue and i think it wouldn't be an issue as onCreate is called immediately after onAttach in lifecycle.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
listnener = (TilesOnClickListnener)getActivity();
} catch (ClassCastException e) {
throw new ClassCastException(getActivity().toString() + " must implement OnArticleSelectedListener");
}
}