Created
October 30, 2014 03:21
-
-
Save manijshrestha/62fe7f9755c9f265ae11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void provisionOwner() { | |
DevicePolicyManager manager = | |
(DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); | |
ComponentName componentName = BasicDeviceAdminReceiver.getComponentName(this); | |
if(!manager.isAdminActive(componentName)) { | |
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); | |
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName); | |
startActivityForResult(intent, 0); | |
return; | |
} | |
if (manager.isDeviceOwnerApp(getPackageName())) | |
manager.setLockTaskPackages(componentName, new String [] {getPackageName()}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment