Disable Device Manager - Android Hardware

Android examples for Hardware:Device Feature

Description

Disable Device Manager

Demo Code


//package com.java2s;
import android.app.admin.DeviceAdminReceiver;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Context;

public class Main {

    private static void unactiveDeviceManager(Context context,
            Class<? extends DeviceAdminReceiver> cls) {
        DevicePolicyManager dpm = (DevicePolicyManager) context
                .getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName receiver = new ComponentName(context, cls);
        if (isDeviceManagerActive(context, cls)) {
            dpm.removeActiveAdmin(receiver);
        }/*from  www.  ja  v  a2  s.c o  m*/
    }

    public static boolean isDeviceManagerActive(Context context,
            Class<? extends DeviceAdminReceiver> cls) {
        DevicePolicyManager dpm = (DevicePolicyManager) context
                .getSystemService(Context.DEVICE_POLICY_SERVICE);
        ComponentName receiver = new ComponentName(context, cls);
        return dpm.isAdminActive(receiver);
    }
}

Related Tutorials