开发者

Java.net.UnknownHostException using httpGet on Android

开发者 https://www.devze.com 2023-03-10 05:53 出处:网络
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:

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

精彩评论

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