Android Question java.lang.SecurityException: Admin does not have

ykucuk

Well-Known Member
Licensed User
Longtime User
While developing an app using B4A and trying to utilize Samsung Knox APIs for Kiosk Mode, I encountered the following error:

B4X:
java.lang.SecurityException: Admin  does not have com.samsung.android.knox.permission.KNOX_KIOSK_MODE

This error indicates that the app lacks the required permissions or configurations in the manifest to access the Knox Kiosk Mode functionality.

Manifest Code
Below is the manifest configuration I used:

B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="26" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true" 
    android:normalScreens="true"
    android:exported="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)        
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")

CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
CreateResourceFromFile(Macro, FirebaseAnalytics.Firebase)
CreateResourceFromFile(Macro, FirebaseNotifications.FirebaseNotifications)
CreateResourceFromFile(Macro, FirebaseAnalytics.FirebaseAnalytics)
CreateResourceFromFile(Macro, FirebaseAuth.FirebaseAuth)
AddPermission(android.permission.READ_EXTERNAL_STORAGE) ' Allows an application to read from external storage.
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE) ' Allows an application to write to external storage.
AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.sec.MDM_ENTERPRISE_CONTAINER)
AddPermission(android.permission.sec.MDM_APP_MGMT)
AddPermission(android.permission.sec.MDM_KIOSK_MODE)
AddPermission(com.android.launcher.permission.INSTALL_SHORTCUT)
AddManifestText(
<uses-permission android:name="com.samsung.android.knox.permission.KNOX_RESTRICTION_MGMT"/>)
AddApplicationText(<receiver android:name="com.sentio.admin"
  android:permission="android.permission.BIND_DEVICE_ADMIN">
  <meta-data android:name="android.app.device_admin"
  android:resource="@xml/device_admin" />
  <intent-filter>
  <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
  </intent-filter>
</receiver>)
CreateResource(xml, device_admin.xml,
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-policies>
       <limit-password />
        <watch-login />
        <reset-password />
        <force-lock />
        <wipe-data />
         <allow-attachments />
        <limit-attachments />
        <allow-storagecard />
        <allow-camera />
        <allow-wifi />
        <allow-textmessaging />
        <allow-popimapemail />
        <allow-htmlemail />
        <allow-browser />
        <allow-internetsharing />
        <require-manualsyncroaming />
        <allow-bluetoothmode />
        <max-calendarage />
        <max-emailage />
        <max-emailbodytruncsize />
        <max-htmlemailbodytruncsize />
        <require-signedsmimemessages />
        <require-encryptedsmimemessages />
        <require-signedsmimealgorithm />
        <require-encryptionsmimealgorithm />
        <allow-smimeencryptionalgonegotiation />
        <allow-smimesoftcerts />
        <allow-desktopsync />
        <allow-irda />
        <require-device-encryption />
        <require-storagecard-encryption />
        <encrypted-storage />
        <mdm-application />
        <mdm-bluetooth />
        <mdm-device-inventory />
        <mdm-date-time />
        <mdm-exchange-account />
        <mdm-roaming />
        <mdm-wifi />
        <mdm-security />
        <mdm-email-account />
        <mdm-hardware-control />
        <mdm-tethering />
        <mdm-location />
        <mdm-calling />
        <mdm-email />
        <mdm-vpn />
        <mdm-apn-settings />
        <mdm-browser-settings />
        <mdm-phone-restriction />
        <mdm-firewall />
        <mdm-enterprise-vpn />
        <mdm-data-time />
    </uses-policies>
</device-admin>
)
[code/]
 
Top