title: How to prevent a user from disabling my device admin app, through the settings menu?
body: <p>I'm working on an MDM (Mobile Device Management) app for android, but I have a huge problem and it's that the user can disable my app from within settings>security>device administrators. The only thing I can do about it, is display a warning message by overriding the <code>onDisableRequested(...)</code> method in my <code>DeviceAdminReceiver</code> sub-class, but I really want to prevent the user from disabling my admin app altogether.</p>
  
  <p>I've tried to override the <code>onReceive(...)</code> method, so that nothing happens when the actions ACTION_DEVICE_ADMIN_DISABLE_REQUESTED and ACTION_DEVICE_ADMIN_DISABLED are broadcasted by the system, but so far it has not worked. Apparently some other component is processing those actions before they arrive to my <code>onReceive(...)</code> method and I dont know why. I would like to be able to show my own custom dialog indicating that the user can´t disable the administrator app from this section, and maybe even ask the user to set an admin password to do it.</p>
  
  <pre><code>public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          if (ACTION_PASSWORD_CHANGED.equals(action)) {
              onPasswordChanged(context, intent);
          } else if (ACTION_PASSWORD_FAILED.equals(action)) {
              onPasswordFailed(context, intent);
          } else if (ACTION_PASSWORD_SUCCEEDED.equals(action)) {
              onPasswordSucceeded(context, intent);
          } else if (ACTION_DEVICE_ADMIN_ENABLED.equals(action)) {
              onEnabled(context, intent);
          } else if (ACTION_DEVICE_ADMIN_DISABLE_REQUESTED.equals(action)) {
  
          } else if (ACTION_DEVICE_ADMIN_DISABLED.equals(action)) {
  
          } else if (ACTION_PASSWORD_EXPIRING.equals(action)) {
              onPasswordExpiring(context, intent);
          }
      }  
  </code></pre>
  
  <p>I need help to solve this issue.</p>
  
  <p>Thanks, </p>