Code example for DevicePolicyManager

Methods: isAdminActive, lockNow

0
        private OnClickListener mForceLockListener = new OnClickListener() {
            public void onClick(View v) { 
                if (mAM.isUserAMonkey()) { 
                    // Don't trust monkeys to do the right thing! 
                    AlertDialog.Builder builder = new AlertDialog.Builder(Controller.this); 
                    builder.setMessage("You can't lock my screen because you are a monkey!"); 
                    builder.setPositiveButton("I admit defeat", null); 
                    builder.show(); 
                    return; 
                } 
                boolean active = mDPM.isAdminActive(mDeviceAdminSample); 
                if (active) { 
                    mDPM.lockNow(); 
                } 
            } 
        }; 
 
        private OnClickListener mWipeDataListener = new OnClickListener() {
            public void onClick(final View v) { 
                if (mAM.isUserAMonkey()) { 
                    // Don't trust monkeys to do the right thing!