4

In my game I'm trying get opponent's profile picture, but getIconImageUri() returns null, code below only show in log Uri to my profile picture. I also have same problem with player name. My player name is fully displayed (First and Last name) but opponents name is something like "player_123".

    for (Participant p : mParticipants) {

        if (p.getIconImageUri() != null) {
            Log.d(TAG, "avatar " + p.getIconImageUri().toString());
        }
        //  ImageUtils.downloadAvatar(p.getIconImageUri().toString());
    }
user1483208
  • 385
  • 5
  • 24

2 Answers2

4

This sounds like you are connecting with Players that are not in the same circle of sharing. Is this from an invite game or a Random game? (auto-pick)

If you are inviting players, and they are accepting your invite to play, then there may be an issue. Otherwise, it is normal Google+ behavior to not give out the icon or name of Participants if circle matching isn't complete.

From Android Developer Participant

public abstract Uri getHiResImageUri ()

Returns the URI of the hi-res image to display for this participant. If the identity of the player is unknown, this will be null. It may also be null if the player simply has no image.

To retrieve the Image from the Uri, use ImageManager. Returns

The URI of the hi-res image to display for this participant. 

public abstract Uri getIconImageUri ()

Returns the URI of the icon-sized image to display for this participant. If the identity of the player is unknown, this will be the automatch avatar icon image for the player. It may also be null if the player simply has no image.

To retrieve the Image from the Uri, use ImageManager. Returns

The URI of the icon image to display for this participant. 

public abstract String getParticipantId ()

Returns the ID of this participant. Note that this is only valid for use in the current multiplayer room: a participant will not have the same ID across multiple rooms. Returns

The ID of this participant. 

public abstract Player getPlayer ()

Returns the Player that this participant represents. Note that this may be null if the identity of the player is unknown. This occurs in automatching scenarios where some players are not permitted to see the real identity of others. Returns The Player corresponding to this participant.

user2346305
  • 1,912
  • 14
  • 21
  • I'm using automatching but players have each other in circles. I'm trying download image in onRoomConnected, so I need to do this later? – user1483208 Nov 28 '13 at 13:14
  • auto matching is treated as if the players are completely anonymous to each other, so unless you send an invite, and accept it to play... will always be null and no name for the Participant (although looking at documentation, it appears that Google is planning, or there is a way now, to do an Avatar for auto-match) After onRoomConnected is where I handle this behavior as well for my invite games... – user2346305 Nov 29 '13 at 11:47
-1

Try saving your name, image and unique id in your database on google login and send your id to participants in onRoomConnected() and retrieve participant's image and name from database with the help of received unique id from participant.

AlvaroAV
  • 10,335
  • 12
  • 60
  • 91