Lock the Android device programmatically

The activity class should be inner class and the outter class should extend DeviceAdminReceiver public class adminActivity extends DeviceAdminReceiver { public static class Controller extends Activity { DevicePolicyManager mDPM; ComponentName mDeviceAdminSample; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); mDeviceAdminSample = new ComponentName(Controller.this, adminActivity.class); } } } To lock the device write the code … Read more

How to make my app a device owner?

There’s actually a way other than NFC and rooting to set an application as a device owner app. You could use the dpm command line tool from an adb shell. Usage : usage: dpm [subcommand] [options] usage: dpm set-device-owner <COMPONENT> usage: dpm set-profile-owner <COMPONENT> <USER_ID> dpm set-device-owner: Sets the given component as active admin, and … Read more