My Android device is requesting a png image on the server. The server encodes the image in Base64 and sends it to my device. After that, I decode the Base64 string into a byte array and use BitmapFactory.decodeByteArray () to create its bitmap. I do not see the image when I add it to ImageView.
See below code:
JSONObject params = resultObject.getJSONObject("params");
byte[] decodedImageInBytes = Base64.decode(params.getString("image_one"), Base64.DEFAULT);
Bitmap myImage = BitmapFactory.decodeByteArray(decodedImageInBytes, 0, decodedImageInBytes.length);
ImageView imageViewOne = (ImageView) findViewById(R.id.imageViewOne);
imageViewOne.setImageBitmap(myImage);
Edit:
It seems that my code is ok, I have problems with the server. Thanks everyone!
source
share