I have the Google Map API v2 working fine on Android using a SupportMapFragment in a FragmentActivity.
However, when there is no network connection (and no cached information), obviously, no map can be shown. LogCat gives me an error message confirming this ("Google Maps Android API: Failed to load map. Could not connect to Google servers"), but this is not thrown.
How can I detect this case programmatically, because I would like to forward to a different Activity in this case? The docs claim that if no map could be loaded getMap() called on the SupportMapFragment would return null, but this does not seem to be the case.
I've been searching around for almost two days for a solution, but was not able to find anything. Am I totally overlooking something or is it really not possible to find out whether something was actualy loaded? Any help is greatly appreciated.
Edit:
Here is my current code, the error message appears on the logs after the setContentView is executed (checked with debugger), but it still says that ConnectionResult == SUCESS.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SupportMapFragment smf = ((SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map));
map = smf.getMap();
if (map != null && GooglePlayServicesUtil.isGooglePlayServicesAvailable(this) ==
ConnectionResult.SUCCESS) {
// doSomething with the map
} else {
Toast.makeText(this, "Google Maps not working", Toast.LENGTH_SHORT).show();
System.out.println(GooglePlayServicesUtil.isGooglePlayServicesAvailable(this));
// forward to another activity
}
}