Ken
Ken

Reputation: 31161

android, httpurlconnection error

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?

Upvotes: 9

Views: 9902

Answers (1)

superfell
superfell

Reputation: 19040

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" />

Upvotes: 20

Related Questions