使用JSON从WCF REST返回图像到android应用程序

本文关键字:图像 android 应用程序 返回 REST JSON WCF 使用 | 更新日期: 2023-09-27 18:08:00

我试图通过JSON从c#返回一个复杂的对象到android应用程序。图像部分给我带来了困难因为这一行被吹掉了

String responseEntity = EntityUtils.toString(response.getEntity());

从我读过的和其他资源看来,EntityUtils.toString()是为大型图像数据做的错误方法,我看到很多使用InputStreamEntity的例子从android发送到WCF REST web服务,但没有使用其他方式的例子,接收数据并解码成android对象类型。

谁能告诉我做这件事的正确方法?

使用JSON从WCF REST返回图像到android应用程序

wcf响应的内容类型是什么如果是原始图像数据你可以这样做

Bitmap  image =BitmapFactory.decodeStream(response.getEntity().getContent())