Cannot resolve method 'getSupportFragmentManager ( )' inside Fragment

Solution 1:

Inside a Fragment subclass you have to use getFragmentManager in place of getSupportFragmentManager. You will get the support one if the import are from the support library.

Solution 2:

For my case, I made sure that Fragment class is imported from

android.support.v4.app.Fragment

Not from

android.app.Fragment

Then I have used

getActivity().getSupportFragmentManager();

And now its working. If I use activity instance which I got in onAttach() is not working also.

Solution 3:

Extends FragmentActivity instead of Activity

Solution 4:

Use getActivity().getSupportFragmentManager()