i got a UnknowHostException
<p>I was trying to run a example project from pro android2, but I get an exception and have no idea how to resolve it.</p>

<p>Here is the code:</p>

<p><strong>Purejava.java</strong></p>

<pre><code>package com.purejavaz;

import android.app.Activity;
import android.os.Bundle;

public class Purejava extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        TestHttpGet get = new TestHttpGet();
        try {
            get.executeHttpGet();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
</code></pre>

<p><strong>TestHttpGet.java</strong></p>

<pre><code>package com.purejavaz;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;

public class TestHttpGet {

    public void executeHttpGet() throws Exception {
    BufferedReader in = null;
    try {
        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(new URI("http://code.google.com/android/"));
        HttpResponse response = client.execute(request);
        in = new BufferedReader
(new InputStreamReader(response.getEntity()
            .getContent()));

        StringBuffer sb = new StringBuffer("");
        String line = "";
        String NL = System.getProperty("line.separator");
        while ((line = in.readLine()) != null) {
            sb.append(line + NL);
        }
        in.close();

        String page = sb.toString();
        System.out.println(page);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
</code></pre>

<p><strong>AndroidManifest.xml</strong></p>

<pre><code>&lt;code&gt;&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.purejavaz"
      android:versionCode="1"
      android:versionName="1.0"&gt;
    &lt;uses-sdk android:minSdkVersion="8" /&gt;
    &lt;permission android:name="android.permission.INTERNET"&gt;&lt;/permission&gt;

    &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
        &lt;activity android:name=".Purejava"
                  android:label="@string/app_name"&gt;
            &lt;intent-filter&gt;
                &lt;action android:name="android.intent.action.MAIN" /&gt;
                &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
            &lt;/intent-filter&gt;
        &lt;/activity&gt;

    &lt;/application&gt;
&lt;/manifest&gt;&lt;/code&gt;
</code></pre>

<p>The log errors:</p>

<pre><code>03-26 10:30:57.205: WARN/System.err(335): java.net.UnknownHostException: code.google.com
03-26 10:30:57.215: WARN/System.err(335):     at java.net.InetAddress.lookupHostByName(InetAddress.java:513)
03-26 10:30:57.215: WARN/System.err(335):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:278)
03-26 10:30:57.225: WARN/System.err(335):     at java.net.InetAddress.getAllByName(InetAddress.java:242)
03-26 10:30:57.225: WARN/System.err(335):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:136)
03-26 10:30:57.225: WARN/System.err(335):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
03-26 10:30:57.235: WARN/System.err(335):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
03-26 10:30:57.245: WARN/System.err(335):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:348)
03-26 10:30:57.245: WARN/System.err(335):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
03-26 10:30:57.245: WARN/System.err(335):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
03-26 10:30:57.245: WARN/System.err(335):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
03-26 10:30:57.255: WARN/System.err(335):     at com.purejavaz.TestHttpGet.executeHttpGet(TestHttpGet.java:20)
03-26 10:30:57.255: WARN/System.err(335):     at com.purejavaz.Purejava.onCreate(Purejava.java:13)
03-26 10:30:57.265: WARN/System.err(335):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-26 10:30:57.265: WARN/System.err(335):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-26 10:30:57.265: WARN/System.err(335):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-26 10:30:57.275: WARN/System.err(335):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-26 10:30:57.275: WARN/System.err(335):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-26 10:30:57.275: WARN/System.err(335):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-26 10:30:57.285: WARN/System.err(335):     at android.os.Looper.loop(Looper.java:123)
03-26 10:30:57.285: WARN/System.err(335):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-26 10:30:57.295: WARN/System.err(335):     at java.lang.reflect.Method.invokeNative(Native Method)
03-26 10:30:57.295: WARN/System.err(335):     at java.lang.reflect.Method.invoke(Method.java:521)
03-26 10:30:57.295: WARN/System.err(335):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-26 10:30:57.295: WARN/System.err(335):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-26 10:30:57.305: WARN/System.err(335):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
