Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从android远程服务器检索blob数据_Android_Mysql - Fatal编程技术网

从android远程服务器检索blob数据

从android远程服务器检索blob数据,android,mysql,Android,Mysql,问题是:我正在尝试从服务器检索android应用程序的blob图像。第一个问题是doInBackground返回字符串,但我想返回位图。另外,我不确定“bitmapImg=BitmapFactory.decodeStream(inputStream);”行是否正确。请帮助,提前感谢 class blobConnect extends AsyncTask<Boolean, String, String> { @Override protected String doInBack

问题是:我正在尝试从服务器检索android应用程序的blob图像。第一个问题是doInBackground返回字符串,但我想返回位图。另外,我不确定“bitmapImg=BitmapFactory.decodeStream(inputStream);”行是否正确。请帮助,提前感谢

   class blobConnect extends AsyncTask<Boolean, String, String> {

@Override
protected String doInBackground(Boolean... params) {
String result = null;
InputStream inputStream = null;
Bitmap bitmapImg = null;
//convert response to string
try {

// http post
HttpClient httpclient = new DefaultHttpClient();
HttpGet httppost = new HttpGet("http://x.x.x.x/android_connect/img.php");
HttpResponse response = httpclient.execute(httppost);
HttpEntity httpEntity = response.getEntity();
inputStream= httpEntity.getContent();
if (response.getStatusLine().getStatusCode() != 200) {
Log.d("MyApp", "Server encountered an error");
}
bitmapImg =BitmapFactory.decodeStream(inputStream);
Log.d("test", bitmapImg);
} catch (Exception e) {
Log.e("log_tag", "Error converting result " + e.toString());
}
return bitmapImg;
}
}
}
类blobConnect扩展异步任务{
@凌驾
受保护字符串doInBackground(布尔值…参数){
字符串结果=null;
InputStream InputStream=null;
位图bitmapImg=null;
//将响应转换为字符串
试一试{
//http post
HttpClient HttpClient=新的DefaultHttpClient();
HttpGet httppost=新的HttpGet(“http://x.x.x.x/android_connect/img.php");
HttpResponse response=httpclient.execute(httppost);
HttpEntity HttpEntity=response.getEntity();
inputStream=httpEntity.getContent();
如果(response.getStatusLine().getStatusCode()!=200){
Log.d(“MyApp”,“服务器遇到错误”);
}
bitmapImg=BitmapFactory.decodeStream(inputStream);
Log.d(“测试”,bitmapImg);
}捕获(例外e){
Log.e(“Log_标记”,“错误转换结果”+e.toString());
}
返回bitmapImg;
}
}
}

Base64编码怎么样?我使用解码将字符串转换为位图来显示图像。是否也需要使用base64编码?您可以让doInBackground返回位图。相应地更改您的类声明。