GooglePlayServicesAvailable何时返回SERVICE_VERSION_UPDATE_REQUIRED?

pom*_*ber 20 android google-play-services

根据文档,当"已安装的Google Play服务版本已过期"时,GooglePlayServicesUtil.isGooglePlayServicesAvailable会返回SERVICE_VERSION_UPDATE_REQUIRED.

这是否意味着Play商店中有新版本的google play服务?
这是否意味着应用程序需要比当前安装在设备中的版本更新的版本?

怎么做这个检查?

tyc*_*czj 11

这意味着您在应用中添加的Google Play服务版本高于用户设备上当前安装的版本.用户需要更新其Google Play服务才能使您的应用正常运行.

如果结果返回错误,您可以简单地调用此方法来提醒用户他们需要更新,并将它们带到那里.

GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE).show();
Run Code Online (Sandbox Code Playgroud)

result是该isGooglePlayServicesAvailable方法的结果


Jar*_*ows 6

以下是以下文档GooglePlayServicesUtil: http ://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html.

以下是他们谈论"确保"用户安装它的地方: https ://developer.android.com/google/play-services/setup.html#ensure

这取自官方Iosched 2014源代码: https ://github.com/google/iosched/blob/0a90bf8e6b90e9226f8c15b34eb7b1e4bf6d632e/android/src/main/java/com/google/samples/apps/iosched/util/PlayServicesUtils. java的

public class PlayServicesUtils {

    public static boolean checkGooglePlaySevices(final Activity activity) {
        final int googlePlayServicesCheck = GooglePlayServicesUtil.isGooglePlayServicesAvailable(activity);
        switch (googlePlayServicesCheck) {
            case ConnectionResult.SUCCESS:
                return true;
            case ConnectionResult.SERVICE_DISABLED:
            case ConnectionResult.SERVICE_INVALID:
            case ConnectionResult.SERVICE_MISSING:
            case ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED:
                Dialog dialog = GooglePlayServicesUtil.getErrorDialog(googlePlayServicesCheck, activity, 0);
                dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialogInterface) {
                        activity.finish();
                    }
                });
                dialog.show();
        }
        return false;
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是如何使用它Activity: https ://github.com/google/iosched/blob/cf1f30b4c752f275518384a9b71404ee501fc473/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java

@Override
protected void onResume() {
    super.onResume();

    // Verifies the proper version of Google Play Services exists on the device.
    PlayServicesUtils.checkGooglePlaySevices(this);
}
Run Code Online (Sandbox Code Playgroud)


hrs*_*krs 5

这是否意味着 Play 商店中有新版本的 google play 服务?

来自网站的最新更新是201412 月

这是否意味着该应用程序需要比设备中当前安装的版本更新的版本?

您可以检查设备的版本是否Google Play Service高于应用程序上的版本,如下所示:

    int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable( getApplicationContext() );
if(status == ConnectionResult.SUCCESS) {
   //OK
}else if(status == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED){
   Toast.makeText(context,"please udpate your google play service",Toast.LENGTH_SHORT).show
}
Run Code Online (Sandbox Code Playgroud)


pom*_*ber 1

文档已更新,现在很清楚:

验证此设备上是否安装并启用了 Google Play 服务,并且此设备上安装的版本不早于此客户端所需的版本