简体   繁体   English

如何检查用户设备上安装了哪个版本的 Google Play GAMES

[英]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. GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE 返回应用所需的最低版本,而不是用户设备上安装的版本。

  1. Is there a way to get the Google Play Services version the user has installed?有没有办法获取用户安装的 Google Play 服务版本?

  2. More importantly, how do I get the Google Play GAMES version installed?更重要的是,如何安装 Google Play GAMES 版本?

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.我运行了我的应用程序并且登录/退出并通过手动和静默登录重新启动没有问题。但是,如果作为用户我在设备上卸载或禁用 Google Play GAMES,所有登录尝试都失败,代码 12501 表示用户已取消。

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?在尝试登录用户之前或登录时,我需要知道 Google Play 游戏是否已安装并且是最新的。我该怎么做?

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:在 Android 11 上,您还需要添加 Manifest 条目以进行包查询:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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