I want to install custom apps or apps from google play store in Work Profile
without user interaction. It can be done using Android Device Policy app and Android Management API remotely only for play store apps.
I've created custom Work Profile
application referring to this sample in android using DevicePolicyManager
and DeviceAdminReceiver
.
I'm able to enable or disable System apps in my Work Profile
using:
packageFlags = PackageManager.MATCH_UNINSTALLED_PACKAGES;
ApplicationInfo applicationInfo = packageManager.getApplicationInfo(packageName, packageFlags);
if (0 == (applicationInfo.flags & ApplicationInfo.FLAG_INSTALLED)) {
if (enabled) {
devicePolicyManager.enableSystemApp(componentName, packageName);
} else {
Log.e(TAG, "Cannot disable this app: " + packageName);
return;
}
} else {
devicePolicyManager.setApplicationHidden(componentName, packageName, !enabled);
}
But I can't find any method to install play store apps or any custom apps (.apk files) in my work profile
, the way it is done using Android Management API
and Android Device Policy app
. Is there any way to do it programmatically?