【问题标题】:How to get the nickname for my Android device set in Google Play Store如何获取我在 Google Play 商店中设置的 Android 设备的昵称
【发布时间】:2012-10-20 00:43:26
【问题描述】:

我有多个相同型号的设备。因此,在 Google Play 商店中,我会看到它们具有相同的名称,默认情况下是运营商 + 制造商 + 型号。因此,哪个是哪个是相当混乱的。我最近发现您可以在“我的订单和设置”-> Google Play 商店网站上的设置下为每台设备设置一个昵称。太好了。但有人知道是否有办法在我的应用程序中检索 Android 上当前设备的昵称?我想在我的应用程序中显示昵称而不是型号。我想如果有办法,它必须通过Google Play Store应用程序提供的API?有任何想法吗?谢谢!

【问题讨论】:

    标签: android api google-play


    【解决方案1】:

    很遗憾,没有官方的 Google Play Store API,因此无法做到这一点。有一个非官方的,一个艰难的,但你不能用这个来做到这一点。

    【讨论】:

    【解决方案2】:

    经过验证的答案已经过时了。

    您可以使用PlayerClient class 从 Google Play 游戏服务获取玩家信息。一旦你得到它,你需要加载玩家的信息,然后你会得到Player class。然后你可以创建一些自定义函数来获取用户详细信息

      public JSONObject get_user_details() {
        JSONObject userDetails = new JSONObject();
    
        // Needs to be loaded before, it is the Player class mentioned before
        if (currentPlayer != null) {
          try {
            userDetails.put("playergame:name", currentPlayer.getDisplayName());
            userDetails.put("playergame:photo_uri", currentPlayer.getIconImageUri());
            userDetails.put("playergame:uid", currentPlayer.getPlayerId());
          } catch (JSONException e) {
            Log.w(TAG, "Failed to load player's game informations: " + e);
          }
        }
    
        return userDetails;
      }
    

    如果你在寻找更好的例子,google 已经发布了samples code on github

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-14
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多