Guide
How to Configure an Android TWA for Kiosk Mode
October 21, 2026 · 8 min read
Dedicated Android devices are increasingly common in retail, hospitality, logistics, and corporate environments. Whether you are building a restaurant ordering screen, an interactive guest check-in terminal, or a warehouse scanning interface, using a Progressive Web App (PWA) packaged as a Trusted Web Activity (TWA) is often the most efficient route. It allows you to ship instantly, run web updates without waiting for app store reviews, and maintain a single codebase.
However, running a public-facing terminal introduces security and operational challenges. You must prevent users from exiting your application, accessing device settings, opening other apps, or tampering with the operating system. To achieve this, you need to configure your TWA to run in what Android calls Lock Task Mode, often referred to as Kiosk Mode. This guide explains how to configure your TWA for absolute lockdown.
Understanding Android Lock Task Mode vs Screen Pinning
Android provides two primary mechanisms to restrict user interaction with a single app. Understanding the difference is critical before deploying your hardware fleet.
| Feature | Screen Pinning (App Pinning) | Lock Task Mode (Kiosk Mode) |
|---|---|---|
| User Escape | Allowed via button combinations and device PIN. | Strictly blocked. Requires administrator intervention. |
| System Bar Visibility | Home and Back buttons remain visible. | System status and navigation bars can be entirely hidden. |
| Target Environment | Personal or shared household devices. | Dedicated enterprise, retail, and industrial hardware. |
| Authorization Method | User-triggered via the Overview screen. | Programmatically triggered by Device Owner apps. |
For a production-grade kiosk deployment, Screen Pinning is insufficient because users can easily bypass it if they know the device passcode. True Lock Task Mode requires the application to be registered as a Device Owner or Profile Owner using Android Enterprise management APIs.
Setting Up the TWA Wrapper for Lock Task Mode
To enable Lock Task Mode in your TWA, you must modify the native Android wrapper. The standard TWA launcher activity needs to be integrated with Android DevicePolicyManager APIs. This configuration determines which packages are allowed to enter the locked state.
1. Declare Device Admin Privileges
Your TWA must first define a device administration receiver in its Android Manifest. This receiver tells the operating system that your app is capable of managing device policies. You define this inside the application block of your manifest file using a receiver tag that points to an XML configuration file specifying the requested policies.
2. Programmatic Lock Activation
In your main TWA activity class, you must retrieve the DevicePolicyManager and verify if your app is authorised to enter Lock Task Mode. If authorised, you trigger the lockdown state when the activity starts. This is done inside the onCreate method of your activity.
You must obtain the DevicePolicyManager instance and your component name. You then check if your package name is present in the list of allowed lock task packages returned by the system. If it is, you call the startLockTask method on the activity. If the app is set as the Device Owner, this method locks the screen instantly without any confirmation dialogs.
3. Graceful Exit Mechanisms
A true kiosk must not be closeable by customers, but your system administrators or maintenance technicians need a way to exit the app for updates or troubleshooting. You can handle this by exposing a hidden gesture or a password-protected admin portal within your PWA.
When the correct administrative credentials are entered inside your PWA, your web application can notify the native wrapper. Once the message is received, the native Android wrapper calls the stopLockTask method. This restores the default system navigation UI and allows the technician to access the Android settings panel.
Crucial Android Manifest Adjustments for Kiosk TWAs
In addition to programmatic locking, you must configure specific manifest settings to ensure the user experience is smooth and unbreakable.
- Default Launcher Category: To prevent the default Android home screen from loading if the device restarts, you must register your TWA as the default launcher. By adding the home and default categories to your main intent filter, pressing the physical or virtual Home button will simply reload your TWA.
- Immersive Mode: To prevent the notification tray from being dragged down from the top of the screen, you should configure your activity to run in full immersive mode. This hides both the status bar and the navigation bar.
- Screen Orientation: Kiosk hardware is typically mounted permanently in either portrait or landscape. Lock this setting in your manifest using the screenOrientation attribute to prevent unwanted layout shifts if the device accelerometer detects movement.
Ensuring Digital Asset Links are Flawless
One of the most common mistakes when deploying a TWA kiosk is neglecting the Digital Asset Links verification process. In a standard consumer TWA, a failed asset verification causes the browser to display an fallback URL bar at the top of the screen. In a kiosk setup, this fallback URL bar is a major security vulnerability, as it allows users to type other web addresses and bypass your app.
Ensure your digital asset relation file is uploaded to your web server at the exact path: /.well-known/assetlinks.json. This JSON file must contain the correct package name of your TWA and the SHA-256 fingerprint of your production signing key. If your device is offline during the very first boot, the verification might fail. Therefore, you must pre-verify or whitelist the verification state in offline staging environments before sending devices to the field.
Handling Power and Wake States
Kiosk terminals are designed to run for hours, often requiring the screen to remain illuminated indefinitely. In a standard Android setup, the system sleep timer will turn off the screen after a few minutes of inactivity. You can solve this in two ways:
First, you can use the native Android window flag FLAG_KEEP_SCREEN_ON within your TWA activity wrapper to force the display to stay active while your app is in the foreground. Second, you can implement the modern web-native Screen Wake Lock API inside your PWA JavaScript code. This ensures that even if you modify your web application later, you can control the wake state dynamically without redeploying the native Android wrapper to the app store or via your MDM system.
Offline Fallbacks and Network Failures
Kiosks deployed in retail settings often suffer from intermittent Wi-Fi drops. A standard web browser would display a generic offline error page, which looks highly unprofessional on a public display. To prevent this, your PWA must implement a robust Service Worker that caches your entire interface shell. If the network drops, the TWA should continue displaying a functional, elegant offline screen that prompts the user or alerts staff, rather than breaking the illusion of a native application.
Ready to ship your Android app?
Paste your PWA URL, get a signed APK and a Google Play ready AAB in minutes.
Build my app