Back to top

Declare Knox permissions

With Knox v3.0, we introduced selective permissions, so that you can declare only the permissions that your app uses. This topic shows how to declare these permissions, and also how to handle app permissions dynamically at runtime as opposed to all at once when the application is installed.

Selective permissions allow you to present app users with a simple pop-up listing only the permissions needed to run your app. These permissions are what you include in your Android manifest. The Knox system grants your app access to only the permissions you declared in your Android manifest.

Declare permissions

The selective permissions feature is optional.

  • If your app does not declare the meta tag, it gets all permissions by default. MDM apps that support the Knox Service Plugin must use this option as KSP needs all the Knox permissions.
  • If your app does declare the meta tag, it gets only the selected permissions.

To use selective permissions:

  1. Look up the required Knox permissions in the API reference. For example, the API method RestrictionPolicy.setCameraState() requires the permission com.samsung.android.knox.permission.KNOX_HW_CONTROL.
  2. Update the Android manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.samsung.knox.example.gettingstarted">

    <!-- Declare the Knox permissions used by this app -->
    <uses-permission android:name="com.samsung.android.knox.permission.KNOX_HW_CONTROL"/>

    <application>
        <!-- Enable the selective Knox permissions -->
        <meta-data android:name="com.samsung.knoxlicense.permissions" android:value="true"/>
    </application>
</manifest>

See also:

Tutorial progress

You’ve completed 5/7 steps!

Next

Is this page helpful?