机器人,HttpURLConnection的错误 [英] android, httpurlconnection error
问题描述
我正在从的Android HttpURLConnection的文档下面的测试Java脚本的:
I'm running the following test Java script from the Android HttpURLConnection docs:
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.connect();
的Eclipse(在我的Mac)告诉我,当我有这个运行在Android模拟器是一个系统错误:
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异常:权限被拒绝
(顺便说一句,当我做等值的Objective-C /可可有一点问题都没有。)
(Incidentally when I do the equivalent in Objective-C/Cocoa there's no problem at all.)
这是什么问题?
推荐答案
您不允许应用程序访问网络,除非它已经宣布,其将在AndroidManifest.xml文件,在<舱单>
元素
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" />
这篇关于机器人,HttpURLConnection的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!