I play with the BasicManagedProfile sample and want to install a custom application for a managed profile only. I can easily go to the game store, download and install the application, and it will only appear in work profile applications.
However, using the standard Intent method to install apk from the device does not work.
final Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE); intent.setDataAndType(Uri.fromFile(new File(APK_LOC)), "application/vnd.android.package-archive"); intent.putExtra(Intent.EXTRA_NOT_UNKNOWN_SOURCE, true); intent.putExtra(Intent.EXTRA_INSTALLER_PACKAGE_NAME, getPackageName()); startActivityForResult(intent, REQUEST_INSTALL, null);
As usual, if the “Install from unknown sources” security option is not enabled, a dialog box will appear that will send you to the Settings application to enable it. However, in a managed profile application, this dialog always appears regardless of whether this security setting is set. It seems that the settings are not reflected in the managed profile (which makes sense because it is a completely separate settings database).
I tried to open the Settings app directly, but it's still the same. It just fits the default settings of the application, and not the settings of the managed profile settings.
Is there a way to change this security setting for a managed profile or install the application from the profile owner application? Since my application is the owner of the profile, it seems like this should be allowed. This is easily possible for system applications, but third-party applications will not work with the DevicePolicyManager#enableSystemApp() method.
EDIT:
I also tried installing from the Manage Profile Gmail application. Same. Unable to install apps outside of the Google Play store in a managed profile.
source share