When does isGooglePlayServicesAvailable return SERVICE_VERSION_UPDATE_REQUIRED?

后端 未结 5 1199
清酒与你
清酒与你 2020-12-17 09:32

According to the documentation GooglePlayServicesUtil.isGooglePlayServicesAvailable returns SERVICE_VERSION_UPDATE_REQUIRED when \"The installed version of Google Play servi

相关标签:
5条回答
  • 2020-12-17 10:14

    Note that all of the current answers reference GooglePlayServicesUtil which is now deprecated. See GooglePlayServicesUtil vs GoogleApiAvailability for details on how to perform the Google Play Services version compatibility check.

    0 讨论(0)
  • 2020-12-17 10:16

    Does this mean that there is a new version of google play services in the play store?

    From the site latest update was on December 2014

    Does this mean that the app needs a newer version than the one that is currently installed in the device?

    You can check if the device has the higher version ofGoogle Play Service than the one on your app like so:

        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
    }
    
    0 讨论(0)
  • 2020-12-17 10:20

    this means that the version of google play service you included in your app is higher than the one currently installed on the users device. the user needs to update their google play services in-order for your app to work correctly.

    if the result comes back with that error you can simply call this method to alert the user they need to update and it will take them there.

    GooglePlayServicesUtil.getErrorDialog(result, this, GOOGLE_PLAY_SERVICE_UPDATE_CODE).show();
    

    result is the result of the isGooglePlayServicesAvailable method

    0 讨论(0)
  • 2020-12-17 10:24

    Documentation was updated, now it is clear:

    Verifies that Google Play services is installed and enabled on this device, and that the version installed on this device is no older than the one required by this client.

    0 讨论(0)
  • 2020-12-17 10:29

    Here are the docs for GooglePlayServicesUtil: http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html.

    Here is where they talking about "ensuring" the user has it installed: https://developer.android.com/google/play-services/setup.html#ensure

    This is taken from the Official Iosched 2014 source code here: 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;
        }
    }
    

    Here is how to use it in an 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);
    }
    
    0 讨论(0)
提交回复
热议问题