官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 阿坝县| 诸暨市| 扬州市| 桑植县| 迁安市| 台南县| 太湖县| 乐业县| 沈阳市| 乾安县| 兴文县| 筠连县| 新乡市| 东光县| 台江县| 肥东县| 宁南县| 博湖县| 济源市| 汝阳县| 台南县| 双江| 淄博市| 仁怀市| 余庆县| 蒲城县| 南宁市| 新兴县| 邻水| 钟祥市| 西乌珠穆沁旗| 本溪市| 宁城县| 陕西省| 前郭尔| 沭阳县| 杂多县| 六枝特区| 宜城市| 正镶白旗| 抚宁县|