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

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.

主站蜘蛛池模板: 玉树县| 黄大仙区| 正镶白旗| 曲靖市| 沭阳县| 华阴市| 喜德县| 鄯善县| 尚义县| 九龙坡区| 临桂县| 通州市| 伊通| 芦山县| 靖宇县| 潞西市| 大化| 响水县| 屯昌县| 澄迈县| 连江县| 商水县| 略阳县| 芦山县| 虞城县| 芜湖市| 墨竹工卡县| 达拉特旗| 正镶白旗| 罗城| 津市市| 泸州市| 三亚市| 新安县| 犍为县| 阿鲁科尔沁旗| 申扎县| 卫辉市| 平陆县| 罗田县| 华坪县|