Search code examples
androidlockingadministration

android how to disable changing through apps


currently I am working on a parental control app and I want the child keep from removing the app. For this, I want to lock the device when the child wants to disable my app from device admins (in settings/security) and show an activity to enter the password. But after the activity is shown, I can still use the device by changing through apps (by double square button on the device, I don't know its name).

How can I lock the device such that the user only can see my password asking activity & can't do anything but either enter the password or cancel?


Solution

  • Are you talking about the kiosk mode in android ?

    please follow How to implement kiosk mode in android ?

    here on Back / Home / Minimize button you can open your dialog for password and if password is true then finish() your current activity.

    you can also use KeyEvent for that

    public boolean onKeyDown(int keyCode, KeyEvent event)  
    {
         if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
         {
            this.moveTaskToBack(true);
            return true;
         }
        return super.onKeyDown(keyCode, event);
    }
    

    you can find all android keys here