Code example for DevicePolicyManager

Methods: isAdminActivelockNow

0
    @Override 
    public void onCreate(){ 
        Log.v(TAG, "LockScreenService Started!!!!");
        mDPM = (DevicePolicyManager)getSystemService(Context.DEVICE_POLICY_SERVICE);
        mAdminReceiver = new ComponentName(this, AdminReceiver.class);
        if(mDPM.isAdminActive(mAdminReceiver)){
            mDPM.lockNow();
        } 
        else{ 
            Intent myIntent = new Intent(this, AdminPermissionSet.class);
            myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(myIntent);
        } 
        stopSelf();
    } 
     
    @Override 
    public IBinder onBind(Intent intent) {
        return mBinder;
    } 
Experience pair programming with AI  Get Codota for Java