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.