Search code examples
androidiosnativescripthardware

NativeScript - how to enable and disabled the hardware controls?


I'm building an app with NativeScript 6.4.1 and Angular 8.

We want to be able to disable and enable the hardware controls of the phone at will. I need to be able to do that for both iOS and Android.

I want to disable the back button, the home button etc. all the buttons that could be at the bottom of the device.

I have tried to look through the documentation and I could not find a way to do this: https://docs.nativescript.org

How can I do that?


Solution

  • You can not disable hardware buttons, but you can override the behavior. We have back button activityBackPressed event out of the box, you may decide wether to cancel the default behavior and perform your own action.

    If you want to override home / menu button, you will have to create your own activity and override keydown callback. Here is how you do it in native android, could be ported to {N}.