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" />
精彩评论