How to prevent user from leaving app or locking user in the same screen?

Solution 1:

Samsung as a manufacturer has special privileges and access to System APIs that the normal app developer will not. I know you can consume the Back button at the Activity level but you can't consume the Home button or Overview button.

Both keycodes

KEYCODE_APP_SWITCH(Overview) and KEYCODE_HOME are not delivered to your Activity but are instead handled by the OS which is Samsung flavor of Android and they can then intercept and handle those codes as they see fit.

I believe in much older versions of Android like pre-4.0 you could do something like this easily, but its an obvious security risk. So only system apps can use this kind of stuff in modern Android.

Depending on the phone you can disable these buttons via Settings, meaning you could prompt the parent to disable them on first startup.

All in all if you do figure out a kinda solution it wont be pretty.

 //Here is the way you can catch the back button though.
 @Override
 public boolean onKeyDown(int keyCode, KeyEvent event) {\
     //Catch the back key and return
     if(KeyEvent.KEYCODE_BACK == keyCode){
         return false;
     }
     return super.onKeyDown(keyCode, event);
 }

EDIT: You also have the Flutter/Dart tags, and you even have more restrictions with using that api instead of the native one.