2

I'm making an Android app using Xamarin and C#. The app will always be running in Kiosk-mode in which the bottom navigation bar of the device will be removed and navigation outside of the app is blocked.

However, when the user connects a bluetooth keyboard they can hit the physical home button and return to the android home screen which should not be accessible.

I'm aware that there are ways to disable the home button, but I haven't been able to get any of them to work properly as they're generally hacks since Android doesn't directly allow developers to intercept the home button.

Is there anyway I can remap the home key of bluetooth keyboards connected? Are there any other solutions to this that I maybe overlooking?

Community
  • 1
  • 1
Vito
  • 1,580
  • 1
  • 17
  • 32

2 Answers2

1

You can't intercept Android Home Button due to security of device, however if you have rooted device you can experiment with Android Key Layout Files https://source.android.com/devices/input/key-layout-files.html

But that requires root on device

jakubbialkowski
  • 1,546
  • 16
  • 24
0
  1. Another method with root is to find the correct /dev/input/eventX device, get exclusive access to it, and then use the /dev/uinput interface to create a new device. Then write all events from the keyboard other than home key to the new interface. I haven't tested this, but in theory it should work.

  2. You could perhaps create a dummy launcher that simply exits as soon as it starts. But it would disable the home button altogether, not just on the BT keyboard.

Alexander Pruss
  • 365
  • 3
  • 10