I already know how to read a xml file from local storage. But now I would like to get the news from Yahoo! [link: http://hk.news.yahoo.com/rss/hong-kong ]
I use the code as below but it returns error, what is wrong?!?!
String source = "http://hk.news.yahoo.com/rss/hong-kong";
URL url = new URL(source);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestMethod("GET");
urlConnection.connect();
InputStreamReader in = new InputStreamReader(urlConnection.getInputStream());
BufferedReader br = new BufferedReader(in);
String result = br.readLine();
Log.i(tag, "GET success: " + result);
br.close();
in.close();
The error log is :
05-22 14:34:25.696: E/RSS(24465): java.net.ConnectException: failed to connect to hk.news.yahoo.com/2406:2000:ac:8::c:9102 (port 80): connect failed: EHOSTUNREACH (No route to host)
THANKS!!
Check you Application internet permission in android Androidmenifest.xml.
<uses-permission android:name="android.permission.INTERNET" />
Thanks