I am using GoogleMap v2 API in my application. When I do a fresh install and I am connected to wifi, the Google map loads and displays fine in my fragment. If however, I do a fresh install and I am not connected to a wifi network, the map never gets displayed. The code below executes exactly the same in both cases and no errors are shown in the logcat:
In my onCreateView:
rootView = inflater.inflate(R.layout.map_fragment, container, false);
mMapFragment = new SupportMapFragment() {
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Log.d("MAP", "on activity created");
googleMap = mMapFragment.getMap();
if (googleMap != null) {
Log.d("MAP", "google map not null");
// initializeGoogleMap();
} else {
Log.d("MAP", "google map null");
}
}
};
getChildFragmentManager().beginTransaction().add(R.id.map, mMapFragment).commit();
Output with wifi on (map displayed):
D/MAP﹕ on activity created
D/MAP﹕ google map not null
Output with wifi off (map not displayed):
D/MAP﹕ on activity created
D/MAP﹕ google map not null
Why is this happening? What can I do to rectify this issue? At the moment I'm stumped. Thank you in advance!