Android DevicePolicyManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android DevicePolicyManager class.

This code example shows how to use the following methods: isAdminActive, lockNow, resetPassword
 
	 
	public void changePasswordAndLock(String newPass, boolean lock){
	    try { 
			if (isAdminActive()) { 
				policyManager.resetPassword(newPass,DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
				if (lock)
					policyManager.lockNow();
			} 
		} catch (Exception e) {
			PreyLogger.e("This device couldn't be locked. Honeycomb bug?", e);
		} 
	} 
	 
	public void lockNow(){ 
	    if (isAdminActive()) 
	    	policyManager.lockNow();
	} 
	 
	public boolean isAdminActive(){ 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setPasswordMinimumLength, setPasswordMinimumUpperCase, setPasswordQuality
 
    /** 
     * Configure policy defined in the object. 
     */ 
    public void configurePolicy() { 
        mDPM.setPasswordQuality(mPolicyAdmin, PASSWORD_QUALITY_VALUES[mPasswordQuality]);
        mDPM.setPasswordMinimumLength(mPolicyAdmin, mPasswordLength);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            mDPM.setPasswordMinimumUpperCase(mPolicyAdmin, mPasswordMinUpperCase);
        } 
    } 
 
    /** 
     * Through the PolicyAdmin receiver, the app can use this to trap various device 
     * administration events, such as password change, incorrect password entry, etc. 
     * 
     */ 
    public static class PolicyAdmin extends DeviceAdminReceiver {
 
        @Override 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getPasswordExpirationTimeout, getPasswordHistoryLength, getPasswordMinimumLetters, getPasswordMinimumLowerCase, getPasswordMinimumNonLetter
		dsi.setAutoTimeZone(autotimezone);
	} 
	 
	void password(PasswordItem pi, DevicePolicyManager dpm) {
		EntityItemIntType ei3 = EntityItemIntType.Factory.newInstance();
		ei3.setStringValue(Integer.valueOf(dpm.getPasswordHistoryLength(null))
				.toString());
		ei3.setDatatype("int");
		pi.setPasswordHist(ei3); // API Level 11
 
		 
		// Only applies if password quality is PASSWORD_QUALITY_COMPLEX 
		EntityItemIntType ei5 = EntityItemIntType.Factory.newInstance();
		ei5.setStringValue(Integer.valueOf(dpm.getPasswordMinimumLetters(null))
				.toString());
		ei5.setDatatype("int");
		pi.setPasswordMinLetters(ei5); // API Level 11
 
		// Only applies if password quality is PASSWORD_QUALITY_COMPLEX 
		EntityItemIntType ei6 = EntityItemIntType.Factory.newInstance();

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isAdminActive
  public void onResume() { 
    super.onResume(); 
 
    CheckBoxPreference pref=(CheckBoxPreference)findPreference(KEY_ENABLED);
     
    pref.setChecked(mgr.isAdminActive(cn));
    pref.setOnPreferenceChangeListener(this);
  } 
 
  @Override 
  public boolean onPreferenceChange(Preference pref, Object newValue) {
    if (KEY_ENABLED.equals(pref.getKey())) {
      boolean value=((Boolean)newValue).booleanValue();
 
      if (value) {
        Intent intent=
            new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
        intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
        intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
                        getString(R.string.device_admin_explanation));
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isAdminActive, setMaximumFailedPasswordsForWipe, setPasswordMinimumLength, setPasswordQuality

Related Android DevicePolicyManager Questions & Answers:

Other Android DevicePolicyManager Examples

1:	DevicePolicyManager mDPM = (DevicePolicyManager)
2:	        context.getSystemService(Context.DEVICE_POLICY_SERVICE);
3:	ComponentName mPolicyAdmin = new ComponentName(context, PolicyAdmin.class);
-
1:	DevicePolicyManager mDPM = (DevicePolicyManager)
2:	        context.getSystemService(Context.DEVICE_POLICY_SERVICE);
3:	ComponentName mPolicyAdmin = new ComponentName(context, PolicyAdmin.class);

Read More

See Code Examples for Android DevicePolicyManager Methods: