2
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を実行しているSamsung galaxy tab 2を使用しています

4

1 に答える 1