简体   繁体   中英

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. When I hover cursor over "this" it shows

Create (android.content.Context) in ImageManager cannot be applied to (anonymous com.google.android.gms.tasks.OnCompleteListener)

Don't use CircleImageView library ie , 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.

Here is the final working code.

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

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