Unable to call getSupportFragmentManager in Fragment

Hi all,

I am trying to setup a map with routing in a fragment instead of activity.

However when I initialize Map Fragment, as below:

MapFragment mapFragment = (MapFragment) getSupportFragmentManager().findFragmentById(R.id.someIDHere);

The studio has a red underline under getSupportFragmentManager . Just wonder if anyone here knows where goes wrong? I use the same code in activity and works
Thank you.

Hi.

It’s hard to tell because we don’t have a full source code, but most probably you are not deriving from AppCompatActivity class.

Regards,
Mateusz