I'm using Google Maps API V2 in an activity wih drop down navigation where the map is on the second position.
I'm adding the map pragmatically like:
mMapFragment = supportMapFragment.newInstance();
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.placeHolder, mMapFragment, TAG_MAP)
.commit();
I want to get the GoogleMap ovject, as the documentation https://developers.google.com/maps/documentation/android/map say it should be done with mMapFragment.getMap()
, but it returns null.
according to http://developer.android.com/reference/com/google/android/gms/maps/SupportMapFragment.html it returns null if the Fragment hasn't gone through the onCreateView lifecycle event.
how can I know whenever the fragment is ready ?
EDIT: I found this How do I know the map is ready to get used when using the SupportMapFragment?
Overriding onActivityCreated seems like a solution, but then I'll have to instantiate the fragment through a constructor and not with newInstance(), does it make any difference ?