I am trying to use getSupportFragmentManager() inside MainActivity class which extends MapActivity but I am getting following error which I am unable to resolve.
"The method getSupportFragmentManager() is undefined for the type MainActivity"
Previously I was extending FragmentActivity and it was working fine but now I want to add mapoverlay that is why I am extending MapActivity.
Here is the portion of associated code
public class MainActivity extends MapActivity {
GoogleMap googleMap;
MarkerOptions markerOptions;
LatLng latLng;
Geocoder geoCoder;
EditText editText;
GeoPoint p;
MapController controller;
MapView mapView;
Button btnSearch;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int status = GooglePlayServicesUtil
.isGooglePlayServicesAvailable(getBaseContext());
if (status != ConnectionResult.SUCCESS) {
// Google Play Services are not available
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this,
requestCode);
dialog.show();
}
else {
// Getting reference to the SupportMapFragment
SupportMapFragment fragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
// Getting Google Map
googleMap = fragment.getMap();
MapView mapView = (MapView) findViewById(R.id.mapView);
addListenerOnButton();
}
}