0

I'll try to explain my problem as clear as I can. I have an web api that returns me an byte[]. enter image description here

When I convert that to a Byte[] and feed it to BitmapFactory.decodeByteArray() it gives me null, but it's an valid byte array. enter image description here

These images returned by the web api are user submitted logos of their companies and I can't control the formats on which they are uploaded. Is there a way to make it onto a valid bitmap or drawable?

Edit: I realized I had an " at start and at the end of the string, I removed them in my work code and I'm still having the issue.

ycs.lrodz
  • 47
  • 6
  • 3
    Looks like it's Base64 encoded. Did you try decoding it thusly? http://stackoverflow.com/questions/4837110/how-to-convert-a-base64-string-into-a-bitmap-image-to-show-it-in-a-imageview – Mike M. Nov 22 '16 at 17:20
  • Thanks for the reply @MikeM. this got me through but when I set the bitmap to an image view, it's all blank... But at least bitmap factory returns a valid bmp – ycs.lrodz Nov 22 '16 at 17:38
  • 1
    I solved the issue for the blank image. Thanks @Mike M. I upvoted your reply, but cannot mark it as the answer. – ycs.lrodz Nov 22 '16 at 17:43
  • Oh, I didn't notice the edit to your comment earlier. I just went ahead and closed it as a duplicate of that question, since it had the code you needed. Thanks, anyway. Glad you got it working. Cheers! – Mike M. Nov 22 '16 at 19:37

0 Answers0