1

I am getting the URI from google with this method:

Player me = Games.Players.getCurrentPlayer(mGoogleApiClient);
Uri uri = me.getHiResImageUri();

I read in various posts that because of Google's security restrictions I need to use the ImageManager class.

This class only provides voids which directly set the URI as the drawable for the ImageView I provide. This is the method: loadImage(ImageView imageView, Uri uri);

The problem is that I need to get a variable of the Drawable class from this Uri and use that. Having the Uri set as the drawable of the image does not work in my specific case. I don't know if there is a class similar to ImageManager or if there is a workaround to get the drawable.

Thanks for all replies in advance!

2 Answers2

0

One approach is to use HttpURLConnection and call the URL, you'll then get the InputStream and use it to instantiate a BitMap by decoding it thru BitmapFactory.decodeStream. As indicated by @seƱor-reginold-francis in his answer, don't forget to add the "User-agent" property as it may be denied access if its absent (considering you're getting it from a google domain)

Community
  • 1
  • 1
adjuremods
  • 2,938
  • 2
  • 12
  • 17
0

You still have to determine yourself what you want to do with the image.

final ImageView imgView = (ImageView) findViewById(R.id.imageView);
ImageManager.create(context)
    .loadImage(new ImageManager.OnImageLoadedListener() {
        @Override
        public void onImageLoaded(Uri uri, Drawable drawable, boolean b) {
            imgView.setImageDrawable(drawable);
        }
}, participant.getHiResImageUri(), R.drawable.placeholder);
xorgate
  • 2,244
  • 1
  • 24
  • 36