android - 使用 imageview 显示 google play 游戏服务玩家图像

标签 android google-play google-play-services google-play-games leaderboard

我正在使用 Google Play 游戏服务并使用此代码获取玩家详细信息。

if (gamesClient != null) {
        Games.Leaderboards.loadCurrentPlayerLeaderboardScore(gamesClient, 
                activity.getString(R.string.leaderboard_high_score), 
                LeaderboardVariant.TIME_SPAN_ALL_TIME, 
                LeaderboardVariant.COLLECTION_SOCIAL).setResultCallback(new ResultCallback<Leaderboards.LoadPlayerScoreResult>() {

            @Override
            public void onResult(Leaderboards.LoadPlayerScoreResult result) {
                // TODO Auto-generated method stub
                LeaderboardScore lbs = result.getScore();
                int score = (int) lbs.getRawScore();
                String name = lbs.getScoreHolderDisplayName();
                Uri urlimage = lbs.getScoreHolderHiResImageUri();
                Uri urlicon = lbs.getScoreHolderIconImageUri();
                Log.e("tag", "name: "+name+"\nscore: "+score+"\nurlimage: "+urlimage+"\nurlicon: "+urlicon);
            }
        });
} else {
            //Login
}

但在这里我得到了像“content://com.google.android.gms.games.background/images/33407107/22”这样的个人资料图片链接 有了这个我如何使用 ImageView 在我的应用程序中显示个人资料图像请帮助我。 谢谢..

最佳答案

我尝试使用 ImageManager 像这样:

    Uri icon = Games.Players.getCurrentPlayer(googleApiClient).getIconImageUri();

    ImageManager manager = ImageManager.create(this);
    manager.loadImage(photo, icon);

我还没有在 LeaderboardScore 上尝试过,但我认为它会是一样的。因为 Uri 格式相同 content://com.google.android.gms.games.background/blablabla

关于android - 使用 imageview 显示 google play 游戏服务玩家图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32775503/

相关文章:

android - 在 Android 中拍照后保存缩略图

android - 具有 WRITE_APN_SETTINGS 权限的应用不适用于 Android Market 上的 Galaxy Tab 10.1 GT-P7500

android - 应用程序未在 2.1 市场中显示

android - 如何以编程方式访问 google-services.json 中的 Google API key

android - 使用 Android 7 的 Genymotion 模拟器上的 Google Play 服务

android - 有没有办法在将 minSDK 版本保持为 3 的同时使用 Android 2.1/2.2 中的功能?

android - Gridview如何设计成守护神app

android - 如何仅从一个国家/地区取消发布 android 应用程序?

android - 错误 : more than one library with package name com. google.android.gms.license

android - xmpp 入口 getType