Search code examples
androidjsonandroid-studiopicasso

how to parse image base64 and jpeg from json using picasso


i'm trying to parse an image which is base64 or jpeg. i'm trying to parse base64 first with this code

if(ar.has("foto"))
                    {
                        byte[] decodedString = Base64.decode(ar.getString("foto", Base64.DEFAULT));
                       Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
                    }

but it says getString (String) in JSONObject cannot be applied to (String, int) which is int in red line. it says error in this line of code ("foto", Base64.DEFAULT) . please help


Solution

  • change

    from :

    byte[] decodedString = Base64.decode(ar.getString("foto", Base64.DEFAULT));
    

    to :

    byte[] decodedString = Base64.decode(ar.getString("foto"),  Base64.DEFAULT);