开发者

android, httpurlconnection error

I'm running the following test Java script from the Android HttpURLConnection docs:

URL url = new URL("http://www.android开发者_JS百科.com/");
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.connect();

Eclipse (on my Mac) is telling me there's a system error when I run this in the Android Emulator:

01-13 13:44:32.767: WARN/System.err(1382): java.net.SocketException: Permission denied

(Incidentally when I do the equivalent in Objective-C/Cocoa there's no problem at all.)

What is the problem?


Your application is not allowed to access the network unless it has declared that its going to in the AndroidManifest.xml file, add this inside the <manifest> element.

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜