I found the message Cannot resolve method \'getSupportFragmentManager ( )\' I want to fragment as activity. because I want to use Maps on the tabs swipe.
pub
Extends FragmentActivity instead of Activity
If you're getting "Cannot resolve method getSupportFragmentManager()", try using
this.getSupportFragmentManager()
It works for me when dealing with DialogFragments in android
I tried all above, but none working
Finally tried this my own
getBaseActivity().getFragmentManager()
and is working .. :)
As per the documentation, getSupportFragmentManager() is present only inside AppCompatActivity class. It is not present inside Activity class. So make sure your class extends AppCompatActivity class.
public class MainActivity extends AppCompatActivity {
}
getFragmentManager()
just try this.it worked for my case
Also you can use AppCompatActivity
instead of Activity.
Then getSupportFragmentManager()
will work.
And also not forget to make your App theme extend AppCompat theme in this case