How to find out if an application works or not

I am creating an application that makes my device as a admin work great .

But I want to run some kind of message when my Application uninstall from device.

  • when user remove from admin .

  • How to find out if my app Device admin is checked or not?

I am using android built-in demo of admin application.

Please give me some idea.

+7
android android-layout service admin broadcastreceiver
source share
1 answer

You will need to expand DeviceAdminReceiver and

 public class DeviceAdmin extends DeviceAdminReceiver { @Override public void onEnabled(Context context, Intent intent) { Log.i(this, "admin_receiver_status_enabled"); // admin rights App.getPreferences().edit().putBoolean(App.ADMIN_ENABLED, true).commit(); //App.getPreferences() returns the sharedPreferences } @Override public CharSequence onDisableRequested(Context context, Intent intent) { return "admin_receiver_status_disable_warning"; } @Override public void onDisabled(Context context, Intent intent) { Log.info(this, "admin_receiver_status_disabled"); // admin rights removed App.getPreferences().edit().putBoolean(App.ADMIN_ENABLED, false).commit(); //App.getPreferences() returns the sharedPreferences } } 

anywhere in your application:

 DevicePolicyManager mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE); ComponentName mAdminName = new ComponentName(this, DeviceAdmin.class); if(mDPM != null &&mDPM.isAdminActive(mAdminName)) { // admin active } 
+10
source share

All Articles