Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

uses-permission vs permission for android permissions in the manifest.xml file

People also ask

What is the difference between permission and uses permission in Android?

What is difference between permission and uses-permission in Android? permission is normally used when making a custom permission e.g. when making an app that other apps can tie in to, limiting access is a must. uses-permission is used when your app actually needs a permission it doesn't have normally.

What is Android manifest permission?

The Android manifest file helps to declare the permissions that an app must have to access data from other apps. The Android manifest file also specifies the app's package name that helps the Android SDK while building the app.

Which tag is used for permission in manifest file?

<permission>: The <permission> tag is used to provide access to control some of the app's components.


For

<permission>

The documentation states:

Declares a security permission that can be used to limit access to specific components or features of this or other applications.

Therefore, since you are accessing Android's permissions, you want uses-permission instead. The documentation for this element states:

Requests a permission that the application must be granted in order for it to operate correctly.

<permission> is normally used when making a custom permission (e.g. when making an app that other apps can tie in to, limiting access is a must), and <uses-permission> is used when your app actually needs a permission it doesn't have normally.


Lets start with "uses-permission...": Suppose you want to use GoogleMap in your application as an example to find a nearest location of any office such as bank or any other office. You need internet. So you need to give the permission to your android device to access INTERNET. This is done by using android permission called .

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

Now come to "permission..": what it does is it Declares a security permission that can be used to limit access to specific components or features of this or other applications.If your application need some resources or some feature from other application, you can use by giving the specific class or package.

   <permission android:name="com.example.project.DEBIT_ACCT" . . . />

Thanks. for more information, you can read
http://developer.android.com/guide/topics/manifest/manifest-intro.html


In short, the one you needed is the uses-permission statement.

Androird Document now has a dedicated page discussing these two usages.

In the Using Permissions part, it explains that

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.app.myapp" >
    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    ...
</manifest>

is used to declare what permissions you'd like to use.

While in Defining and Enforcing Permissions you can see that

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.me.app.myapp" >
    <permission android:name="com.me.app.myapp.permission.DEADLY_ACTIVITY"
        android:label="@string/permlab_deadlyActivity"
        android:description="@string/permdesc_deadlyActivity"
        android:permissionGroup="android.permission-group.COST_MONEY"
        android:protectionLevel="dangerous" />
    ...
</manifest>

is used to define your own permission.