Getting java.net.UnknownHostException when using HostName in android
<p>In my android application i have to get XML data from an URL(<code>http://api.offersdb.com/distribution/beta/offers.json?api_key=demo&amp;radius=10&amp;postal_code=30305</code>), for that i am using following code,</p>

<pre><code>try {
        URL url = new URL(urlStr);                                  
        URLConnection urlConn = url.openConnection();
        if (!(urlConn instanceof HttpURLConnection)) {
            throw new IOException("URL is not an Http URL");
        }
        HttpURLConnection httpConn = (HttpURLConnection) urlConn;
        httpConn.setAllowUserInteraction(false);
        httpConn.setInstanceFollowRedirects(true);
        httpConn.setRequestMethod("GET");
        httpConn.connect();
        resCode = httpConn.getResponseCode();
        if (resCode == HttpURLConnection.HTTP_OK) {
            inputStream = httpConn.getInputStream();
        }
    }catch (Exception e) {
        e.printStackTrace();

    }
</code></pre>

<p>But it returns the following exception</p>

<pre><code>java.net.UnknownHostException: Host is unresolved: api.offersdb.com:80
</code></pre>

<p>When i change the Host name (api.offersdb.com) with the ipaddress(XX.XX.XXX.XX) in the URL,i can get the response. I have no idea why i am getting this problem, please somebody help me.</p>

<p>Thanks in Advance,</p>

<p>Rajapandian</p>
