0

I am trying to save the profile picture from Google login, and am kind of a noob at this, so I am doing it in a rather round-about way. There is likely a better way to do this, and if you know it please let me know. But I think there is an unasked question in my round-about way. SO - here we go.

String profilePicUrl = googleSignInAccount.getPhotoUrl().toString();

ImageView intermediaryIV = (ImageView) 
findViewById(R.id.intermediary);
Glide.with(this).load(profilePicUrl).into(intermediaryIV);

ColorDrawable drawable = (ColorDrawable) intermediaryIV.getDrawable();
Bitmap toSaveBitmap = drawable.get; //??

savePicToInternalStorage(toSaveBitmap)

The Glide api (https://github.com/bumptech/glide) loads the image from google into an imageView, and then I grab the drawable from the imageview. But in this case I don't get a normal bitmapDrawable I get a colorDrawable which does not contain a .toBitmap() function. Which causes me a problem because I need to save a bitmap.

So the question is can I convert a colorDrawable to a bitmap?

Also, if you have a better way to save an image from google, would you link me to that in the comments? We can leave the actually post answer to the main question.

M Reza
  • 18,350
  • 14
  • 66
  • 71
chargerstriker
  • 486
  • 1
  • 5
  • 20
  • refer this link https://stackoverflow.com/questions/27394016/how-does-one-use-glide-to-download-an-image-into-a-bitmap –  May 14 '18 at 08:35

1 Answers1

0

You can store the bitmap from the image view drawing cache.

iv.buildDrawingCache();
Bitmap bitmap=iv.getDrawingCache();
eugstman
  • 978
  • 2
  • 15
  • 18