我想在我的应用程序中使用GCM Network Manager
。该库需要在用户设备上安装版本为7.5及以上的Google Play Service
。我想检查一下,如果安装了Google Play Services
并且它的版本高于7.5。我做了如下:支持GCM网络管理器的Google Play服务的最低版本号是多少?
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;
}
问题是我不知道的7.5版本Google Play Services
确切的版本代码在此方法来检查。
可能对您有用,http://www.apk4fun.com/history/1155/ –