0

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();
    }

}
Badrul
  • 1,582
  • 4
  • 16
  • 27
  • Remove `MapView` and your `MainActivity` must extends `FragmentActivity` – M D Apr 15 '14 at 09:10
  • @Simple-Plan that is what I had done before, that was working fine but now I am trying to use map overlay which is why I extended MapActivity & replaced FragmentActivity. Can I use map Overlay by extending FragmentActivity? – Badrul Apr 15 '14 at 09:25
  • 1
    that why i told u remove MapView becoz as Google Map V1 has been deprecated so now you'll implement your functionality with Google Map V2 API – M D Apr 15 '14 at 09:26

0 Answers0