Phonegap Plugin:How to convert Base64 String to a PNG image in Android

后端 未结 3 512
长发绾君心
长发绾君心 2020-11-29 01:35

Android does not allow native apps like Phonegap-based apps to write binary files. A common application is converting Base64 Strings to Images. So, how do you go about this

3条回答
  •  青春惊慌失措
    2020-11-29 02:04

    This solution only works when feeding it a CLEAN Base64 string. In other words, the "data:image/png;base64," part should be removed or the Base64 decoder fill fail, causing a nullpointer error when writing the file.

    Also I noticed that the image does not show up in the Gallery but it is stored correctly on the SD card. When I download it to my PC I can open it just fine. Not sure what that is about.

    Thanks for the work!

提交回复
热议问题