0

I am receiving this response in postman in Android, my response.body() is not null but still, there is no image showing in the image view.

if (response.isSuccessful()) {
    if (response.body()!=null) { 
        Glide.with(getApplicationContext()).load(response.body()).into(iv_userimage_header);
        Toast.makeText(SubtitutesDashboard.this, "Image Set", Toast.LENGTH_SHORT).show();
    }
} 

This is the response of postman

Shashanth
  • 4,995
  • 7
  • 41
  • 51

1 Answers1

2

Try this out, make sure you get the callback for response using okhttp3.ResponseBody. So something like

...
call.enqueue(new Callback<ResponseBody>() {
        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { 
...

And then get your image as a bitmap using

Bitmap bitmap = BitmapFactory.decodeStream(response.body().byteStream());

You can set this bitmap directly to you ImageView

iv_userimage_header.setImageBitmap(bitmap);

Or using Glide with .asBitmap

For more info refer this SO post.

ljk
  • 1,496
  • 1
  • 11
  • 14