如何确保我的应用支持最低版Google Play Services 4.1版本?

Vit*_*y A 2 android google-play-services

如果安装的Google Play服务版本为4.1+,我在检查Google Play服务可用性时需要获取ConnectionResult.SUCCESS:

int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
Run Code Online (Sandbox Code Playgroud)

目前,当Google Play服务版本为5.0.84时,我正在设置代码== ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED.

我知道我所需要的只是添加一些标签,以显示女巫应该包括GooglePlayServices版本代码.但我不知道巫婆一和4.1版本号是什么.请指教.

Vit*_*y A 6

这是我发现到现在为止:

无需对清单文件进行任何更改.

Google Play服务的版本代码是7位数字,其复杂程度与版本名称相同.

例如:

版本4.1.00的代码为4100000,版本6.5.99,代码为6599000

所以,当我需要检查安装的GooglePlayServices是否足够更新时,我会:

int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    ...
    if (code == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) {
        if (GooglePlayServicesUtil.GOOGLE_PLAY_SERVICES_VERSION_CODE >= 4100000)
            result = true;// Meets minimum version requirements
    }
Run Code Online (Sandbox Code Playgroud)