Prevent User from Leaving App
The simplest way to set up kiosk-mode on Android is to use Google's Android Management API which works for any Android devices running Android 5.1 or above.

To lock the device on one app, or on multiple app, you define a kiosk policy like below, it will disable the navigation buttons (sample copied from Create a policy):



"applications": [
 {
   "packageName": "com.example.app",
   "installType": "FORCE_INSTALLED",
   "lockTaskAllowed": true,
   "defaultPermissionPolicy": "GRANT",
 },
"persistentPreferredActivities": [
  {
    "receiverActivity": "com.example.app/.com.example.app.MainActivity",
    "actions": [
      "android.intent.action.MAIN"
    ],
    "categories": [
      "android.intent.category.HOME",
      "android.intent.category.DEFAULT"
    ]
  }
]