我想在我的應用程序中使用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/ –