Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. if ((dpm.getActiveAdmins() != null) && (dpm.isAdminActive(secureLock))) {
  2. Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
  3. intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, secureLock);
  4. intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,"is locked");
  5. dpm.lockNow();
  6. dpm.setMaximumTimeToLock(secureLock, 0);
  7. intent.putExtra("force-locked", DeviceAdminInfo.USES_POLICY_FORCE_LOCK);
  8.  
  9. startActivityForResult(intent, Extra_Activity);
  10. } else {
  11. Log.d("The Device", "Could not lock because device admin not enabled");
  12.  
  13. }
  14.  
  15. }`
  16.  
  17. <receiver
  18. android:description="@string/admin_app_description"
  19. android:label="@string/admin_app"
  20. android:name="app_class_name$MyAdmin"
  21. android:permission="android.permission.BIND_DEVICE_ADMIN" >
  22. <meta-data
  23. android:name="android.app.device_admin"
  24. android:resource="@xml/admin_app_resource" />
  25.  
  26. <intent-filter >
  27. <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
  28. </intent-filter>
  29. </receiver>
  30.  
  31. <uses-permission android:name="android.permission.DISABLE_KEYGUARD" >
  32. </uses-permission>
  33.  
  34. <?xml version="1.0" encoding="UTF-8"?>
  35. <device-admin xmlns:android="http://schemas.android.com/apk/res/android"
  36. android:layout_width="match_parent"
  37. android:layout_height="match_parent" >
  38.  
  39. <uses-policies>
  40.  
  41. <force-lock />
  42. </uses-policies>
  43.  
  44. </device-admin>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement