private HttpResponse doResponse(String url) {
HttpClient httpclient = new DefaultHttpClient(getHttpParams());
HttpResponse response = null;
try {
HttpGet httpget = new HttpGet(url);
response = httpclient.execute(httpget);
} catch (Exception e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
return response;
}
@Override
protected String doInBackground(String... urls) {
// TODO: attempt authentication against a network service.
String url = urls[0];
String result ="";
try {
HttpResponse response=doResponse(url);
result = inputStreamToString(response.getEntity().getContent());
//throws IllegalStateException: Content has been consumed
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
Log.e(TAG, e.getLocalizedMessage(), e);
}
return result;
}
线
result = inputStreamToString(response.getEntity().getContent());
投掷
IllegalStateException: Content has been consumed
即使我之前没有得到内容。
我想知道我的部分代码之前正在使用内容
response.getEntity().getContent();
我在
运行 Android 4.1.1的三星 Galaxy Tab 2