I have a fragment (F1) with a public method like this
public void asd() { if (getActivity() == null) { Log.d(\"yes\",\"it is null\"); } }
Where do you call this function? If you call it in the constructor of Fragment, it will return null.
Fragment
null
Just call getActivity() when the method onCreateView() is executed.
getActivity()
onCreateView()