get HTML code of website from android app
<p>I am developing my first android application.</p>

<p>I try to get the HTML source from a website, i use this code:</p>

<pre><code>    HttpClient client = new DefaultHttpClient();
    HttpGet request = new HttpGet(urlWeb);
    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>Also i add permissions for internet in the Manifest.</p>

<p>But always obtain this error:</p>

<pre><code>05-02 18:56:56.967: E/AndroidRuntime(17659): FATAL EXCEPTION: main
05-02 18:56:56.967: E/AndroidRuntime(17659): java.lang.IllegalStateException: Could not execute method of the activity
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.view.View$1.onClick(View.java:3597)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.view.View.performClick(View.java:4202)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.view.View$PerformClick.run(View.java:17340)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.os.Handler.handleCallback(Handler.java:725)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.os.Handler.dispatchMessage(Handler.java:92)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.os.Looper.loop(Looper.java:137)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.app.ActivityThread.main(ActivityThread.java:5191)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.lang.reflect.Method.invokeNative(Native Method)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.lang.reflect.Method.invoke(Method.java:511)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at dalvik.system.NativeStart.main(Native Method)
05-02 18:56:56.967: E/AndroidRuntime(17659): Caused by: java.lang.reflect.InvocationTargetException
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.lang.reflect.Method.invokeNative(Native Method)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.lang.reflect.Method.invoke(Method.java:511)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.view.View$1.onClick(View.java:3592)
05-02 18:56:56.967: E/AndroidRuntime(17659):    ... 11 more
05-02 18:56:56.967: E/AndroidRuntime(17659): Caused by: android.os.NetworkOnMainThreadException
05-02 18:56:56.967: E/AndroidRuntime(17659):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
05-02 18:56:56.967: E/AndroidRuntime(17659):    at com.example.icpcgb.MainActivity.btn_Show(MainActivity.java:72)
</code></pre>

<p>Wich could be the problem?</p>

<p>Thank you very much</p>
