简体   繁体   中英

How to check what version of Google Play GAMES is installed on user's device

GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE returns the minimum version required by the app, not the version that is installed on the user's device.

  1. Is there a way to get the Google Play Services version the user has installed?

  2. More importantly, how do I get the Google Play GAMES version installed?

I ran my app and had no problems logging in/out and restarting with manual and silent sign in. However, if as the user I uninstall or disable Google Play GAMES on the device all sign in attempts fail with code 12501 indicating user cancelled.

I need to know if Google Play Games is installed and up-to-date before or while attempting to sign the user in. How can I do that?

You can check if package is available:

   fun isGooglePlayGamesInstalled(): Boolean {
      return packageManager.getLaunchIntentForPackage("com.google.android.play.games") != null
   }

On Android 11 you'll also need to add the Manifest entry for package querying:

<manifest package="com.example.game">
    <queries>
        <package android:name="com.google.android.play.games" />
    </queries>
    ...
</manifest>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM