Google suggests (also in docs) calling getErrorDialog()
if the result code is SERVICE_MISSING
, SERVICE_VERSION_UPDATE_REQUIRED
or SERVICE_DISABLED
. So it may be that the last possible status code (SERVICE_INVALID
) is what’s causing trouble.
I’m using the following code and so far it seems to work ok (testing in emulator, platform 2.3.3):
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity.getApplicationContext());
if (resultCode == ConnectionResult.SUCCESS) {
activity.selectMap();
} else if (resultCode == ConnectionResult.SERVICE_MISSING ||
resultCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED ||
resultCode == ConnectionResult.SERVICE_DISABLED) {
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, activity, 1);
dialog.show();
}