user9362291
user9362291

Reputation:

Hide or disable app management programmatically

I am working on app for Point of Sale. I need to disable or hide or ignore user to delete any app. Is there any way to do that?

Upvotes: 0

Views: 1040

Answers (1)

Max M
Max M

Reputation: 81

Try this way:

DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName cn = new ComponentName(context, AdminReceiver.class);
dpm.setUninstallBlocked(cn, packageName, isEnabled);

or

dpm.addUserRestriction(cn, UserManager.DISALLOW_UNINSTALL_APPS);

It needs admin permission (or device owner)

Upvotes: 1

Related Questions