Application level permissions
There are two ways to apply permissions to the entire application. In the first case, an application declares what permissions the application requires to function properly. So, an application that will be sending out SMS will declare such permission in the manifest file. In the second case, the application can declare what permissions other applications trying to interact with this application should have. For example, an application can declare that any application that wants to interact with one of its components should have permissions to access the camera. Both these kinds of permissions have to be declared in the manifest file. Let us go through them one by one.
This <uses-permission>
tag is declared inside <manifest>
and declares what permissions the application requests to function properly. The syntax of the tag is the following:
<uses-permission android:name=" " />
The user, when downloading the application, has to accept these permissions. android:name
is the name of the permission. An example declaration of this tag is as follows. The following permission declares that the application that the user is about to install would access the user's SMS:
<uses-permission android:name="android.permission.READ_SMS"/>
The <application>
tag has an attribute called android:permission
that declares blanket permissions for components. These are the permissions any application trying to interact with this application's components need to have. This is shown in the following code. The following code shows that applications interacting with any component of MyApplication
should have permission to access the camera:
<application android:name="MyApplication" android:icon="@drawable/icon" android:label="@string/app_name""android.permission.CAMERA"/>
As discussed in the next section, individual components can set permissions as well. Component permissions override the permission set using the <application>
tag. The preceding method is the best place to declare the blanket permissions for all components.