I had working code before updating my SDK today(for future reference look at the question asked date). .getMap
used to give warnings that it was deprecated but now it is not even recognized as valid input. I am assuming this has happened because of the new release of API 24(Android Nougat). Without further ado here's the code:
private boolean initMap() {
if (mMap == null) {
MapFragment mapFrag =
(MapFragment) getFragmentManager().findFragmentById(R.id.map);
mMap = mapFrag.getMapAsync();
}
return (mMap != null);
}
If anyone could help me to make changes to integrate .getMapAsync()
I would really appreciate it.
Thank you!
UPDATE: Here's the new and updated code after looking at suggestions in answers(this is NOT in the onCreate)-
private boolean initMap() {
if (mMap == null) {
MapFragment mapFrag = (MapFragment) getFragmentManager()
.findFragmentById(R.id.map);
mapFrag.getMapAsync(this);
}
return (mMap != null);
}
@Override
public void onMapReady(GoogleMap googleMap) {
if (googleMap != null) {
mMap = googleMap;
}
}