Host Is Unresolved - Basic Application (No Proxy)

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

Host Is Unresolved - Basic Application (No Proxy)

Postby nichojo » Wed Oct 08, 2008 12:01 am

This code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.android.weatherapp;
  2.  
  3. import java.net.URL;
  4.  
  5. import javax.xml.parsers.SAXParser;
  6. import javax.xml.parsers.SAXParserFactory;
  7.  
  8. import org.xml.sax.InputSource;
  9. import org.xml.sax.XMLReader;
  10.  
  11. import android.app.Activity;
  12. import android.os.Bundle;
  13. import android.util.Log;
  14. import android.widget.TextView;
  15.  
  16. public class weatherapp extends Activity {
  17.    
  18.     private final String MY_DEBUG_TAG = "AUWeather";
  19.    
  20.     /** Called when the activity is first created. */
  21.     @Override
  22.     public void onCreate(Bundle savedInstanceState) {
  23.         super.onCreate(savedInstanceState);
  24.        
  25.         /* Create a new TextView to display the parsing result later. */
  26.         TextView tv = new TextView(this);
  27.         try
  28.         {
  29.             /* Create a URL we want to load some xml-data from. */
  30.             String queryString = "http://weather.yahooapis.com/forecastrss?p=36832";
  31.             /* Replace blanks with HTML-Equivalent. */
  32.             URL url = new URL(queryString.replace(" ", "%20"));
  33.            
  34.             /* Get a SAXParser from the SAXPArserFactory. */
  35.             SAXParserFactory spf = SAXParserFactory.newInstance();
  36.             SAXParser sp = spf.newSAXParser();
  37.  
  38.             /* Get the XMLReader of the SAXParser we created. */
  39.             XMLReader xr = sp.getXMLReader();
  40.             /* Create a new ContentHandler and apply it to the XML-Reader */
  41.             WeatherHandler myWeatherHandler = new WeatherHandler();
  42.             xr.setContentHandler(myWeatherHandler);
  43.  
  44.             /* Parse the xml-data from our URL. */
  45.             xr.parse(new InputSource(url.openStream()));
  46.            
  47.             /* Parsing has finished. */
  48.             String myText = myWeatherHandler.getInfo();
  49.             tv.setText(myText);
  50.            
  51.         } catch (Exception e)
  52.         {
  53.             tv.setText("Error: " + e.getMessage());
  54.             Log.e(MY_DEBUG_TAG, "WeatherQueryError", e);
  55.         }        
  56.         /* Display the TextView. */
  57.         setContentView(tv);
  58.     }
  59. }
Parsed in 0.039 seconds, using GeSHi 1.0.8.4


Dumps out this:

Code: Select all
10-07 22:55:45.664: ERROR/AUWeather(163): WeatherQueryError
10-07 22:55:45.664: ERROR/AUWeather(163): java.net.UnknownHostException: Host is unresolved: weather.yahooapis.com:80
10-07 22:55:45.664: ERROR/AUWeather(163):     at java.net.Socket.connect(Socket.java:928)
10-07 22:55:45.664: ERROR/AUWeather(163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnection.<init>(HttpConnection.java:61)
10-07 22:55:45.664: ERROR/AUWeather(163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager$ConnectionPool.getHttpConnection(HttpConnectionManager.java:145)
10-07 22:55:45.664: ERROR/AUWeather(163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpConnectionManager.getConnection(HttpConnectionManager.java:67)
10-07 22:55:45.664: ERROR/AUWeather(163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getHTTPConnection(HttpURLConnection.java:800)
10-07 22:55:45.664: ERROR/AUWeather(163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:786)
10-07 22:55:45.664: ERROR/AUWeather(163):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1030)
10-07 22:55:45.664: ERROR/AUWeather(163):     at java.net.URL.openStream(URL.java:664)
10-07 22:55:45.664: ERROR/AUWeather(163):     at com.android.weatherapp.weatherapp.onCreate(weatherapp.java:45)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1122)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2103)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2156)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1580)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.os.Handler.dispatchMessage(Handler.java:88)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.os.Looper.loop(Looper.java:123)
10-07 22:55:45.664: ERROR/AUWeather(163):     at android.app.ActivityThread.main(ActivityThread.java:3742)
10-07 22:55:45.664: ERROR/AUWeather(163):     at java.lang.reflect.Method.invokeNative(Native Method)
10-07 22:55:45.664: ERROR/AUWeather(163):     at java.lang.reflect.Method.invoke(Method.java:515)
10-07 22:55:45.664: ERROR/AUWeather(163):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
10-07 22:55:45.664: ERROR/AUWeather(163):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497)
10-07 22:55:45.664: ERROR/AUWeather(163):     at dalvik.system.NativeStart.main(Native Method)



And I have no idea why. Its almost straight from examples and the URL checks out. I have no proxy either. Any ideas? The internet permission is set as well.
nichojo
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Oct 07, 2008 11:49 pm

Top

Postby Rahul » Tue Oct 14, 2008 1:34 pm

Rahul
Experienced Developer
Experienced Developer
 
Posts: 89
Joined: Wed Oct 01, 2008 11:16 am

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 4 guests