you are probably using android.support.v4.app.Fragment
. For this instead of onAttach
method, just use getActivity()
to get the FragmentActivity
with which the fragment is associated with. Else you could use onAttach(Context context)
method.