简体   繁体   English

Google Play游戏用户个人资料图片未加载

[英]Google play games user profile image not loading

Apologies for reposting the question but I get an error using this method and I can't figure out what I'm doing wrong. 道歉,以重新发布问题,但使用此方法时出现错误,我无法弄清楚自己在做什么错。

  mPlayersClient = Games.getPlayersClient(this, googleSignInAccount);

    mPlayersClient.getCurrentPlayer()
            .addOnCompleteListener(new OnCompleteListener<Player>() {
                @Override
                public void onComplete(@NonNull Task<Player> task) {
                    String displayName;


                    Log.i("playerId" , task.getResult().getPlayerId());
                    if (task.isSuccessful()) {

                        displayName = task.getResult().getDisplayName();
                        Uri uri = task.getResult().getIconImageUri();
                        Log.i("url", uri.toString());

                        CircleImageView imageView = findViewById(R.id.testImage);
                        //ERROR : here when i use "this" it gets red underline
                        ImageManager manager = ImageManager.create(this);
                        manager.loadImage(imageView, uri, R.drawable.defualt_user_img);


                    }

The uri is of content scheme so I can't use Picasso. uri是内容计划,所以我不能使用毕加索。 When I hover cursor over "this" it shows 当我将光标悬停在“ this”上时,它显示

Create (android.content.Context) in ImageManager cannot be applied to (anonymous com.google.android.gms.tasks.OnCompleteListener) 无法将ImageManager中的(android.content.Context)创建应用于(匿名com.google.android.gms.tasks.OnCompleteListener)

Don't use CircleImageView library ie , implementation 'de.hdodenhof:circleimageview:2.2.0' . 不要使用CircleImageView库,即implementation 'de.hdodenhof:circleimageview:2.2.0' Apparently it doesn't support content scheme uri or play games don't support it, not sure which one is the case but it will work fine if you use android ImageView. 显然它不支持内容方案uri或玩游戏不支持它,不确定是哪种情况,但是如果您使用android ImageView,它将可以正常工作。

Here is the final working code. 这是最终的工作代码。

 ImageView imageView = findViewById(R.id.testImage);
 ImageManager manager = ImageManager.create(getApplicationContext());
 manager.loadImage(imageView,uri);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM