I would like to display a message before the user disables device admin for my app. from the Google tutorial page,
http://developer.android.com/guide/topics/admin/device-admin.html
It seems all you do is implement onDisableRequested() in your receiver.
@Override
public CharSequence onDisableRequested(Context context, Intent intent) {
return context.getResources().getString(R.string.device_admin_disable_requested);
}
There’s also an action, android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED. The docs say you must listen for this, but the examples don’t show it in the tutorial, so I’m not sure what I’m supposed to do there, but in my manifest, I have,
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
<action android:name="android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED" />
</intent-filter>
anyway, with the method implemented, and listening for the action, the above callback is not called. Any ideas?
The "disable requested" message appears in a dialog when the user goes to settings > security > device admins and disables the device admin from there.
If you call DevicePolicyManager.removeActiveAdmin() from your app, the method in your device admin receiver is not called and the message is not otherwise displayed to the user. I guess the idea is that if you are calling removeActiveAdmin() from your app, you can throw up any sort of warning you want before allowing the user to do so.