NOTE - As of Knox 3.0, the preferred way to call Knox APIs is to upgrade an Android Work Profile to a Knox Workspace. This tutorial uses Android's Device Manager to call Knox APIs. See Upgrade Android Work Profile to Knox Workspace for more information.

Toggle the Camera state

Now that you have set up the device admin receiver, activated your license, and configured the required permissions, you can use the APIs to toggle the camera state.

Create the camera policy

This method demonstrates how to use the (Undefined variable: Variables.KnoxSDK) to toggle the state of the camera.

 private void CameraPolicy() {

        // Instantiate the EnterpriseDeviceManager class
        EnterpriseDeviceManager enterpriseDeviceManager = EnterpriseDeviceManager.getInstance(this);
        // Get the RestrictionPolicy class where the setCameraState method lives
        RestrictionPolicy restrictionPolicy = enterpriseDeviceManager.getRestrictionPolicy();
        boolean cameraEnabled = restrictionPolicy.isCameraEnabled(false);

        try {
            // Toggle the camera state on/off
            logView(getResources().getString(R.string.camera_state, !cameraEnabled));
        } catch (Exception e) {

Tutorial Progress

You are 9/10 done! Go to the next step.