Android - UnknownHost exception when parsing an RSS feed

十年热恋 提交于 2019-12-18 09:42:05

问题


I want to parse an rss feed from an android application. Everything related to parsing the RSS feed itself is done (using SAX), however I get an exception regarding the name resolution of the feed's url.

This is the line causing the exception:

feedUrl = "http://blog.jonathanbenoudiz.com/feed/"
feedUrl.openConnection().getInputStream();

java.lang.RuntimeException: java.net.UnknownHostException:

So I started investigating my /etc/resolv.conf file and set the nameserver to the dns server of my ISP. Pinging blog.jonathanbenoudiz.com works, but http://blog.jonathanbenoudiz.com and blog.jonathanbenoudiz.com/feed don't work (unknown host).

How am I actually supposed to do this?

Thanks!


回答1:


Add the INTERNET permission to your manifest file.

You have to add this line:

<uses-permission android:name="android.permission.INTERNET" /> 

outside the application tag in your AndroidManifest.xml



来源:https://stackoverflow.com/questions/6125595/android-unknownhost-exception-when-parsing-an-rss-feed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!