Skip to content Skip to sidebar Skip to footer

Google Map:onmapreadycallback Can Not Be Applied To This Activity

I am a beginner trying to use google maps, and I have followed the instructions given here: https://developers.google.com/maps/documentation/android-api/map?hl=zh-tw But I'm stuck

Solution 1:

You need to make your Activity implement OnMapReadyCallback and override the method void onMapReady(GoogleMap googleMap).

public class GoogleMapPage extends FragmentActivity implements OnMapReadyCallback   {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.googlemap);
        MapFragment mapFragment = (MapFragment) getFragmentManager().findFragmentById(R.id.map);
        mapFragment.getMapAsync(this) // <---it said "onMapReadyCallback can not be applied to this activity;
    }


    @Override
    public void onMapReady(GoogleMap googleMap) {
        // Do stuff with the map here!
    }

}

Post a Comment for "Google Map:onmapreadycallback Can Not Be Applied To This Activity"