Android - 解析RSS源时出现UnknownHost异常

时间:2021-12-18 00:59:42

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.

我想从Android应用程序解析rss feed。与解析RSS提要本身相关的所有内容都已完成(使用SAX),但是我得到了关于提要网址的名称解析的例外情况。

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).

所以我开始调查我的/etc/resolv.conf文件,并将nameserver设置为我的ISP的dns服务器。 Pinging blog.jonathanbenoudiz.com有效,但http://blog.jonathanbenoudiz.com和blog.jonathanbenoudiz.com/feed不起作用(未知主机)。

How am I actually supposed to do this?

我该怎么做呢?

Thanks!

1 个解决方案

#1


2  

Add the INTERNET permission to your manifest file.

将INTERNET权限添加到清单文件中。

You have to add this line:

你必须添加这一行:

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

outside the application tag in your AndroidManifest.xml

在AndroidManifest.xml中的应用程序标记之外

#1


2  

Add the INTERNET permission to your manifest file.

将INTERNET权限添加到清单文件中。

You have to add this line:

你必须添加这一行:

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

outside the application tag in your AndroidManifest.xml

在AndroidManifest.xml中的应用程序标记之外