在android应用程序中改装响应正文未正确解析

在android应用程序中改装响应正文未正确解析,android,imageview,postman,retrofit2,Android,Imageview,Postman,Retrofit2,我收到了邮递员的回复 在Android中,我的response.body()不是null,但在图像视图中仍然没有显示图像 if (response.isSuccessful()) { if (response.body()!=null) { Glide.with(getApplicationContext()).load(response.body()).into(iv_userimage_header); Toast.makeText(Subtitut

我收到了邮递员的回复 在Android中,我的response.body()不是null,但在图像视图中仍然没有显示图像

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();
    }
} 

这是邮递员的回答


尝试一下,确保使用
okhttp3.ResponseBody
获得响应的回调。大概是

...
call.enqueue(new Callback<ResponseBody>() {
        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { 
...
您可以直接将此位图设置为
ImageView

iv_userimage_header.setImageBitmap(bitmap);
或者将滑动与
.asBitmap


有关更多信息,请参阅。

您的方式是错误的。因为,您不能使用
response.body()
方法。您可以使用
response.body().byteStream()
方法。试试这个。@MustafaYanık Glide.with(getApplicationContext()).load(response.body().byteStream())到(iv_userimage_头);仍然没有设置图像OK。您可以将ByTestStream转换为Glide支持的格式(uri、字节数组等)。你能试试这个吗?@MustafaYanık你能告诉我怎么做来帮我一点忙吗?有什么原因不能使用glide直接加载url吗?
iv_userimage_header.setImageBitmap(bitmap);