开发者

Can't get android to connect to the Internet (permission denied)

Here's my code:

URL url = new URL("http://www.bing.com/");
        URLConnection urlConnection = url.openConnection();
        BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
        in.close();

In the manifest, I have this开发者_JAVA技巧:

<permission android:name="android.permission.INTERNET"></permission>

It is outside the application tab, but inside the manifest tag.

And the error I'm getting is this:

java.net.SocketException: Permission denied (maybe missing INTERNET permission)

Really not sure why I'm getting this error when I have the internet permission in place. A bit stumped here!

Thanks!


Shouldn't you have the following?

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

(Note the spelling modification between permission and uses-permission)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜