Php 如何将图像从sql数据库发送到android客户端?
我正在尝试将一个图像从sql数据库发送到android客户端。我是通过php中间人来做这件事的。由于下面的方法返回null,代码停止工作。 我的php代码(可以很好地将图像编码到base64中(对编码进行了解码,并且工作正常)):Php 如何将图像从sql数据库发送到android客户端?,php,android,sql,image,Php,Android,Sql,Image,我正在尝试将一个图像从sql数据库发送到android客户端。我是通过php中间人来做这件事的。由于下面的方法返回null,代码停止工作。 我的php代码(可以很好地将图像编码到base64中(对编码进行了解码,并且工作正常)): 我的android代码: public static Bitmap getIm(String IP, int height, int width) { ArrayList<NameValuePair> nameValuePairs = new
我的android代码:
public static Bitmap getIm(String IP, int height, int width)
{
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//Network queries and gets response(works)
String result = Network.getResponse(IP, nameValuePairs);
//manually decode string since for some reason JSON decode won't work(also works)
String r=result.split(":\"")[1];
r=r.split("\"")[0];
//decode string
byte[] decodedString = Base64.decode(r, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
return decodedByte;
//returns null
}
公共静态位图getIm(字符串IP、整数高度、整数宽度)
{
ArrayList nameValuePairs=新的ArrayList();
//网络查询和获取响应(works)
字符串结果=Network.getResponse(IP,nameValuePairs);
//手动解码字符串,因为出于某种原因,JSON解码无法工作(也可以工作)
字符串r=result.split(“:\”)[1];
r=r.split(“\”)[0];
//解码字符串
字节[]decodedString=Base64.decode(r,Base64.DEFAULT);
位图decodedByte=BitmapFactory.decodeByteArray(decodedString,0,decodedString.length);
返回解码字节;
//返回空值
}
public static Bitmap getIm(String IP, int height, int width)
{
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
//Network queries and gets response(works)
String result = Network.getResponse(IP, nameValuePairs);
//manually decode string since for some reason JSON decode won't work(also works)
String r=result.split(":\"")[1];
r=r.split("\"")[0];
//decode string
byte[] decodedString = Base64.decode(r, Base64.DEFAULT);
Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
return decodedByte;
//returns null
}