Reputation: 363
While testing a location based app in Android 4.4 we were able to properly see and use map via Android maps v2
Since the time I upgraded to Android L it is not able to fetch MapFragment with the following code:
In MainActivity there's a FrameLayout in which I load ShowMapFragment.
In ShowMapFragment there is a MapFragment to display map.
Inside 'OnCreateView()' method
mapFragment = (MapFragment)getFragmentManager().findFragmentById(R.id.map);
map = mapFragment.getMap();
mapFragment is coming as null. Any help on this?
Upvotes: 3
Views: 2274
Reputation: 363
Got it. Posting this if anyone else faces the same issue. Basically we have to use getChildFragmentManager()
instead of getFragmentManager()
because the MapFragment is inside another fragemnt. See the answer by Rhisiart here.
Upvotes: 14