Unable to get android to connect to the Internet (permission denied)

Here is 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 the following:

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

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

And the error I get is this:

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

Really not sure why I get this error when I have permission on the Internet. This is a bit of a dead end!

Thanks!

+4
source share
1 answer

You should not have the following?

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

(Note the spelling change between permission and usage permission)

+11
source

Source: https://habr.com/ru/post/1337705/


All Articles