ここに問題があります:私はandroid.firstの問題は、doInBackgroundが文字列を返すことですが、bitmap.また、「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;
}
}
}