Code example for DevicePolicyManager

Methods: isAdminActive, removeActiveAdmin

0
      @Override 
      public void onClick(View v)
      { 
        // TODO Auto-generated method stub 
        // °±¥Î 
        myDPM.removeActiveAdmin(myDeviceAdminReceiver);
        updateButtonStates(); 
      } 
 
    }); 
 
    Button03.setOnClickListener(new OnClickListener()
    { 
 
      @Override 
      public void onClick(View v)
      { 
        // TODO Auto-generated method stub 
        // ¨ú±oÂI¿ïªºRadioButtonªºid 
        int rid = RadioGroup01.getCheckedRadioButtonId();
        // ¨ú±o±K½X³Ì¤pªø«× 
        String minStr = "" + EditText01.getText();
        int min = 0;
        if (!minStr.equals(""))
        { 
          min = Integer.parseInt(minStr);
        } 
        if (rid != -1)
        { 
          if (active)
          { 
            for (int i = 0; i < ids.length; i++)
            { 
              if (ids[i] == rid)
              { 
                myDPM.setPasswordQuality(myDeviceAdminReceiver,
                    myPasswordQuality[i]);
                // min=0¥Nªí¨S­­¨î³Ì¤pªø«×¡Amin<4·|¥H4¬°³Ì¤pªø«× 
                myDPM.setPasswordMinimumLength(myDeviceAdminReceiver, min);
                Intent intent = new Intent(
                    DevicePolicyManager.ACTION_SET_NEW_PASSWORD);
                startActivity(intent);
                break; 
              } 
            } 
          } 
        } else 
        { 
          Toast.makeText(EX05_27_1.this, "½Ð¿ï¾Ü¤@ºØ±K½X®æ¦¡", Toast.LENGTH_SHORT)
              .show();
        } 
      } 
 
    }); 
 
    Button04.setOnClickListener(new OnClickListener()
    { 
 
      @Override 
      public void onClick(View v)
      { 
        // TODO Auto-generated method stub 
        // ­«³]±K½X 
        if (active)
        { 
          myDPM.resetPassword(EditText02.getText().toString(),
              DevicePolicyManager.RESET_PASSWORD_REQUIRE_ENTRY);
        } 
      } 
 
    }); 
 
  } 
 
  void updateButtonStates() 
  { 
    active = myDPM.isAdminActive(myDeviceAdminReceiver);
    if (active)
    { 
      Button01.setEnabled(false);
      Button02.setEnabled(true);