Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. if (!mDPM.isAdminActive(mDeviceAdminSample)) {
  2. // try to become active – must happen here in this activity, to get result
  3. Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
  4. intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,mDeviceAdminSample);
  5. intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,"Admin is added to do security operation.");
  6. startActivityForResult(intent, 0);
  7. } else {
  8. // Already is a device administrator, can do security operations now.
  9. mDPM.lockNow();
  10. }
  11.  
  12. KeyguardManager manager = (KeyguardManager)context.getSystemService(KEYGUARD_SERVICE);
  13. kl = manager.newKeyguardLock("my-remote-app");
  14. kl.disableKeyguard();
  15.  
  16. onDestroy() {
  17. kl.reenableKeyguard();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement