[Android]除非您更新 google 播放服务,否则此应用不会 运行

[Android]This app won't run unless you update google play services

我为我的应用程序实现了一个 google 帐户登录按钮,当我打开应用程序 (Android 6.0.1) 并进入登录页面时,它会显示一个对话框说 除非您更新 google 播放服务,否则此应用不会 运行

这是我的代码:

compile 'com.google.android.gms:play-services:9.2.1'
compile 'com.google.android.gms:play-services-auth:9.2.1'

public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestEmail()
                .build();
        mGoogleApiClient = new GoogleApiClient.Builder(getActivity().getApplicationContext())
                .addApi(Auth.GOOGLE_SIGN_IN_API)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .build();
        mGoogleApiClient.connect();
    }

我检查了我 android 设备上的 google 播放服务是 8.1.86 是不是因为8.1<9.2? 对于已过时 google 播放服务应用程序的用户,如何避免出现此消息?

要检查 Google 播放服务,您可以使用 int isGooglePlayServicesAvailable (Context) 方法:

    GoogleApiAvailability.getInstance()
        .isGooglePlayServicesAvailable(context);

如果 resultCode = SUCCESS then everything is fine. Otherwise, you decide what to do, if SERVICE_VERSION_UPDATE_REQUIRED 您可以询问用户是否要更新或者您可能有其他登录选项。

如果你要显示原始对话框调用 boolean showErrorDialogFragment (Activity activity, int errorCode, int requestCode)