安卓,httpurl连接错误
我正在运行 Android HttpURLConnection 文档 中的以下测试 Java 脚本:
URL url = new URL("http://www.android.com/");
HttpURLConnection urlConnection = (HttpURLConnection)
url.openConnection();
urlConnection.connect();
当我在 Android 模拟器中运行此命令时,Eclipse(在我的 Mac 上)告诉我出现系统错误:
01-13 13:44:32.767: WARN/System.err(1382): java.net.SocketException: Permission被拒绝
(顺便说一句,当我在 Objective-C/Cocoa 中执行等效操作时,根本没有问题。)
问题是什么?
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 (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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不允许您的应用程序访问网络,除非它在 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.