Code example for DevicePolicyManager

Methods: isAdminActive, setMaximumTimeToLock

0
                    } 
                }); 
                builder.setNegativeButton("No way!", null); 
                builder.show(); 
            } 
        }; 
 
        private OnClickListener mSetTimeoutListener = 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) { 
                    long timeMs = 1000L*Long.parseLong(mTimeout.getText().toString());