检索用户的Google Play游戏服务个人资料数据

时间:2017-09-20 11:38:43

标签: android google-play-services

我试图让用户的个人资料图片放入我的游戏布局,有没有办法做到这一点?

我试过这个,但从未被触发过!

public void onResult(Leaderboards.LoadPlayerScoreResult result) {
    // TODO Auto-generated method stub
    ImageView image = (ImageView) findViewById((R.id.IDImage));
    LeaderboardScore lbs = result.getScore();
    int score = (int) lbs.getRawScore();
    String name = lbs.getScoreHolderDisplayName();
    Uri urlimage = lbs.getScoreHolderHiResImageUri();
    Uri urlicon = lbs.getScoreHolderIconImageUri();
    ImageManager manager = ImageManager.create(this);
    manager.loadImage(image, urlicon);
}

我可以得到一些帮助!谢谢!!

1 个答案:

答案 0 :(得分:0)

这些方法属于Player class,其他方法完成它的方法是将调用置于函数内并调用该函数。

从此SO post

public void showPlayerImage(int imgViewId) {
    ImageView image = (ImageView) findViewById(imgViewId);

    Player me = Games.Players.getCurrentPlayer(mGoogleApiClient);

    ImageManager mgr = ImageManager.create(this);
    mgr.loadImage(image, me.getIconImageUri());
}