Android - Kiosk Mode - Single App Mode


I want to have a single app on my device which will start on device start and can’t be exited without a pin. Can this be done with nativescript? If it’s possible, can you provide me an example?
Note: It’s an App for an mounted Android Product Scanner Device.


Try using the native API mentioned in the docs here, that should work


Hi Michael,

Did you managed to make your kiosk app ?
And if so, would you mind sharing your experience, and even pieces of code ?



Hello. I’m sorry for my late answer. I managed to create a single app Mode. My Device has following properties:

  • only one Hardware-Button, which is a Home-Button
  • Android 5.1

I managed to prevent the user from exiting by using an Overlay, Immersive Mode and set the App as Home App.
To create the overlay and start the Immersive Mode i wrote a Plugin based on the following Sites:

To prevent the Home-Button, i set the App as Home App.

Example Code:

Draw Overlay:

    private void preventStatusBarExpansion(Context context, Activity activity) {
        WindowManager manager = ((WindowManager) context.getApplicationContext()
        WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams();
        localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
        localLayoutParams.gravity = Gravity.TOP;
        localLayoutParams.flags =
                WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE |
                        WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | // this is to enable the notification to recieve touch events
                        WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; // Draws over status bar

        localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
        localLayoutParams.height = (int) (25 * context.getResources()
        localLayoutParams.format = PixelFormat.RGBX_8888;
        bottom = new CustomViewGroup(context);
        manager.addView(bottom, localLayoutParams);

    private static class CustomViewGroup extends ViewGroup {
        public CustomViewGroup(Context context) {

        protected void onLayout(boolean changed, int l, int t, int r, int b) {

        public boolean onInterceptTouchEvent(MotionEvent ev) {
            // Intercepted touch!
            return true;

Activate Immersive Mode

    activateKioskMode: function() {
		// set immersive mode
		var flags = android.view.View.SYSTEM_UI_FLAG_LAYOUT_STABLE
		| android.view.View.SYSTEM_UI_FLAG_FULLSCREEN
		var window =;
		var decorView = window.getDecorView();
		// diable user to leave immersive mode
		var context =;
        var kiosk = new de.hh.iap.kioskmode.KioskMode();  // This is my Android Class
        kiosk.activateKioskMode(context,, false);