Android - 解析 RSS 提要时出现 UnknownHost 异常 [英] Android - UnknownHost exception when parsing an RSS feed
问题描述
我想解析来自 android 应用程序的 rss 提要.与解析 RSS 提要本身相关的所有工作都已完成(使用 SAX),但是我收到了有关提要 url 的名称解析的异常.
这是导致异常的行:
feedUrl = "http://blog.jonathanbenoudiz.com/feed/"feedUrl.openConnection().getInputStream();
<块引用>
java.lang.RuntimeException:java.net.UnknownHostException:
所以我开始调查我的 /etc/resolv.conf
文件并将名称服务器设置为我的 ISP 的 dns 服务器.Ping blog.jonathanbenoudiz.com
有效,但 http://blog.jonathanbenoudiz.com
和 blog.jonathanbenoudiz.com/feed
不起作用工作(未知主机).
我该怎么做?
谢谢!
向清单文件添加 INTERNET 权限.
你必须添加这一行:
在您的 AndroidManifest.xml 中的应用程序标记之外
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!
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
这篇关于Android - 解析 RSS 提要时出现 UnknownHost 异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!