开发者

Java.net.UnknownHostException using httpGet on Android

I am attempting to use a yahoo finance api that returns a stock quote as a cvs file in Android. I've reduced the code down to:

HttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
HttpGet httpGet = new HttpGet("http://download.finance.yahoo.com/d/quotes.csv?s=msft&f=sl1p2");

I'm getting the following error "java.n开发者_如何学Pythonet.UnknownHostException: download.finance.yahoo.com"

The link works so I'm not sure why I'm getting the exception. Any help is appreciated.


I had the same problem, by entering the following in AndroidManifest.xml solved it:

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


Add the INTERNET permission to your manifest file. like below

<manifest xlmns:android...> ...
    <application android:label="@string/app_name" >...
    </application>    
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
</manifest>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜