Neranja Gunarathne Neranja Gunarathne - 4 months ago 46
Android Question

how can fixed getMap() method in new APIs in android?this method has a error now

please help sample code is

SupportMapFragment mapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(;
mMap = mapFragment.getMap();

but it's not working.then i replace getMapAsync(this)method.also but not working my code.please tell me a solution.
thank you.


you need to implement OnMapReadyCallback

public class MainActivity extends Activity implements OnMapReadyCallback{


so code for onCreate() will be

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(;

and overrided method onMapReady() will look like below

public void onMapReady(GoogleMap googleMap) {
    mMap = googleMap;