Differences between Uses-Permission and Permissions tag in AndroidManifest.xml

Android

Android Problem Overview


What is the difference between Uses-Permission and Permissions tag in AndroidManifest.xml . I understood uses-permission tag as it is used to access Internet,Location from our application. But I did not understand when and why should we use permissions tag in Manifest file and what is its difference from uses-permission.

Android Solutions


Solution 1 - Android

Quoting the documentation:

> To enforce your own permissions, you > must first declare them in your > AndroidManifest.xml using one or more > <permission> tags. For example, an application that wants to control who can start one of its activities could declare a permission for this operation as follows:

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

Hence, <uses-permission> is when your application is seeking the user's permission to use some feature, while <permission> is when your application is requiring other apps to seek the user's permission to use some feature of yours.

Solution 2 - Android

Simply:

  • <permission> is for defining a custom permission.

  • <uses-permission> is for using a permission in your app.

You may also be interested in security problems with custom permissions as of Feb. 2018. Their explanation of permissions in section 2 seemed far more clear to me than the documentation.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAndroid_programmer_cameraView Question on Stackoverflow
Solution 1 - AndroidCommonsWareView Answer on Stackoverflow
Solution 2 - AndroidjeyreyView Answer on Stackoverflow