Menu

Is it possible to install an app silently on a device using Knox SDK?

Yes, use the ApplicationPolicy class to install apps without user interaction.

 //sample test package name
 String testpackageName = "com.sample.packagename";
 EnterpriseDeviceManager edm = EnterpriseDeviceManager.getInstance(context);
 ApplicationPolicy appPolicy = edm.getApplicationPolicy();
 try {
     boolean result = appPolicy.installApplication(testpackageName);
     if (true == result) {
         Log.d(TAG, "Installing an application package has been successful!");
     } else {
         Log.w(TAG, "Installing an application package has failed.");
     }

 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }

This can also be done inside a container.

//sample test package name
 String testpackageName = "com.sample.packagename";
 // When you create container successfully, containerID will be returned via intent.
 // Use this containerID in below API.
 EnterpriseKnoxManager ekm = EnterpriseKnoxManager.getInstance(context);
 KnoxContainerManager kcm = ekm.getKnoxContainerManager(containerID);
 ApplicationPolicy appPolicy = kcm.getApplicationPolicy();

 try {
     boolean result = appPolicy.installApplication(testpackageName);
     if (true == result) {
         Log.d(TAG, "Installing an application package has been successful!");
     } else {
         Log.w(TAG, "Installing an application package has failed.");
     }

 } catch (SecurityException e) {
     Log.w(TAG, "SecurityException: " + e);
 }
 
Share it: