Google Play services: How to handle devices that do not have Google Play?

前端 未结 4 994
栀梦
栀梦 2020-12-13 19:27

Google Play services is an Android library whose goal is to provide:

  • OAuth 2.0 authentication
  • Google+ sign-in
  • Google+ +1 button
  • vari
4条回答
  •  心在旅途
    2020-12-13 19:54

    GooglePlayServicesUtil.isGooglePlayServicesAvailable(android.content.Context)
    

    is deprecated!

    Use:

     GoogleApiAvailability api = GoogleApiAvailability.getInstance();
            int code = api.isGooglePlayServicesAvailable(activity);
            if (code == ConnectionResult.SUCCESS) {
               // Do Your Stuff Here
            } else {
               AlertDialog alertDialog =
                     new AlertDialog.Builder(activity, R.style.AppCompatAlertDialogStyle).setMessage(
                           "You need to download Google Play Services in order to use this part of the application")
                           .create();
               alertDialog.show();
            }
    

提交回复
热议问题