Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add manifest permission to an application?

I am trying to access HTTP link using HttpURLConnection in Android to download a file, but I am getting this warning in LogCat:

WARN/System.err(223): java.net.SocketException: Permission denied (maybe missing INTERNET permission)

I have added android.Manifest.permission to my application but it's still giving the same exception.

like image 916
rob Avatar asked Jan 30 '10 20:01

rob


People also ask

How do I declare permissions in Android manifest?

To declare a permission only on devices that support runtime permissions—that is, devices that run Android 6.0 (API level 23) or higher—include the uses-permission-sdk-23 element instead of the uses-permission element. When using either of these elements, you can set the maxSdkVersion attribute.


2 Answers

Assuming you do not have permissions set from your LogCat error description, here is my contents for my AndroidManifest.xml file that has access to the internet:

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

Other than that, you should be fine to download a file from the internet.

like image 159
Anthony Forloney Avatar answered Sep 22 '22 08:09

Anthony Forloney


Permission name is CASE-SENSITIVE

In case somebody will struggle with same issue, it is case sensitive statement, so wrong case means your application won't get the permission.

WRONG

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

CORRECT

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

This issue may happen ie. on autocomplete in IDE

like image 42
Marek Sebera Avatar answered Sep 22 '22 08:09

Marek Sebera