Ali Behzadian Nejad Ali Behzadian Nejad - 2 months ago 19
Android Question

What is the minimum version code of Google Play Services that supports GCM Network Manager?

I want to use

GCM Network Manager
in my application. This library needs
Google Play Service
version 7.5 and above installed on user's device. I want to check that if
Google Play Services
is installed and its version is above 7.5. I did as below:

private boolean isGcmNetworkManagerAvailable(Context context) {
final int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(context);
if (status != ConnectionResult.SUCCESS) {
return false;
}

final String gpsPackageName = GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_PACKAGE;
PackageManager pm = context.getPackageManager();
try {
PackageInfo gpsPackageInfo = pm.getPackageInfo(gpsPackageName,0);
int versionCode = gpsPackageInfo.versionCode;
//
// What is the version code of Google Play Services version 7.5?
//
if(versionCode < GOOGLE_PLAY_SERVICES_7_5_VERSION_CODE) {
return false;
}
} catch (PackageManager.NameNotFoundException e) {
return false;
}

return true;
}


Problem is that I don't know the exact version code of
Google Play Services
version 7.5 to check in this method.

Answer

Based on this answer version code of google Play Services is simply a 7-digit number created from its version code so version 7.5 has 7500000 version code.

Comments