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
  • 16,461
  • 14
  • 61
  • 67
chargerstriker
  • 454
  • 1
  • 5
  • 15

1 Answers1

0

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

iv.buildDrawingCache();
Bitmap bitmap=iv.getDrawingCache();
eugstman
  • 868
  • 1
  • 12
  • 18