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

时间:2013-04-03 08:31:25

标签: android mysql

这里的问题是:我正在尝试从服务器上为我的应用程序检索blob图像android.first问题是doInBackground返回字符串但我想返回bitmap.also我不确定“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;
}
}
}

0 个答案:

没有答案