Code example for DevicePolicyManager

Methods: isAdminActive, resetPassword

0
	 
	public static void unlockIfEnabled(Context context) {
		if(PreferenceManager.getDefaultSharedPreferences(context).getBoolean("key_enable_locker", false)) {		
			DevicePolicyManager dpm = ((DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE));
			 
			if (dpm.isAdminActive(new ComponentName(context, CustomDeviceAdminReceiver.class)))
				dpm.resetPassword("", DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
		} 
	} 
	 
	 /** 
	 * Copied from PebbleKit https://github.com/pebble/pebblekit 
	 *   
     * Synchronously query the Pebble application to see if an active Bluetooth connection to a watch currently exists. 
     * 
     * @param context 
     *         The Android context used to perform the query. 
     *         <p/> 
     *         <em>Protip:</em> You probably want to use your ApplicationContext here. 
     * 
     * @return true if an active connection to the watch currently exists, otherwise false. This method will also return