Android HTTP请求RSS Feed

时间:2015-10-13 15:05:13

标签: android json http rss-reader

我正在尝试制作RSS Feed ANDROID应用程序,我从网站下载源代码。但是,它在DefaultHttpClient,HttpPost,HttpResponse和HttpEntity中显示错误。我也手动导入它们但没有变化。请帮帮我!

  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse; 
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;

代码:

   try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();

        BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

0 个答案:

没有答案