简体   繁体   中英

How to get the nickname for my Android device set in Google Play Store

I got multiple devices of the same model. So in Google Play Store, I would see them with the same name which by default is the Carrier + Manufacturer + Model. So it is quite confusing which one is which. I recently found out that you can set a nick name for each device under "My order and settings" -> Settings on Google Play Store website. It is great. But anyone know if there is a way to retrieve the nick names of the current device on Android in my app? I would like to display the nick name rather than the model number in my app. I guess if there is a way, it must be through an API provided by Google Play Store app? Any ideas? Thanks!

Unfortunately there is no official Google Play Store API, so this can't be done. There is one unoffical one tough, but you can't do this with this one eather.

The validated answer is pretty much outdated.

You can get the player's informations from Google Play Games Service using the PlayerClient class . Once you get it, you need to load the player's information and then you will get the Player class . Then you can create some custom function to get user details

  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;
  }

If you are looking for a better example, google has published samples code on github .

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