How to get webpage HTML
<p>I'm trying to load a webpage html in my Android app with the following code:</p>

<pre><code>    HttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet("http://www.stackoverflow.com/");
    HttpResponse response = client.execute(request);

    String html = "";

    InputStream in = response.getEntity().getContent();
    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    StringBuilder str = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
        str.append(line);
    }
    in.close();
    html = str.toString();
</code></pre>

<p>but I'm getting error:
<code>Unhandled exception type ClientProtocolException</code> and <code>Unhandled exception type IOError</code> on third line; and <code>Unhandled exception type IOError</code> on 6th, 10th and 13th line</p>

<p>I have also tried adding try/catch:</p>

<pre><code>    try {
        HttpResponse response = client.execute(request);
    } catch (ClientProtocolException e) {
    } catch (IOException e) {
    }
</code></pre>

<p>but there's error on line <code>InputStream in = response.getEntity().getContent();</code> saying <code>response cannot be resolved</code></p>

<p>(I have Internet access allowed in Manifest)</p>

<p>Where's the problem? Thanks a lot</p>
