Many businesses, schools, and public venues want a single Android device to run one app and prevent users from leaving it. Android offers two built‑in mechanisms:
This tutorial shows both methods, explains when each is appropriate, and walks you through a safe, reproducible setup using only ADB – no rooting, no flashing, and no third‑party launchers.
Make sure you have a computer with adb installed (part of Android SDK Platform‑Tools). If you haven’t installed it yet, download the zip from Google’s developer site, extract it, and add the folder to your system PATH.
Build number seven times.adb devices. You should see the device listed as device (not unauthorized).The device now shows only the pinned app. The back, home, and recent‑apps buttons are disabled. Swiping from the edges or pressing the power button will only turn the screen off – the app stays in the foreground.
To exit, hold the Back and Overview (recent‑apps) buttons simultaneously, or enter the PIN you set earlier. If you never set a PIN, the device will ask for the lock screen credential.
Screen pinning relies on the user to initiate the lock. For truly dedicated devices (e.g., an information kiosk in a lobby), you need a mode that cannot be escaped without an administrator command. That’s where lock task mode comes in.
android:lockTaskMode support.If you already have a kiosk‑ready app (many commercial solutions provide a .apk that can be set as device owner), you can skip step 1 and jump straight to installing it.
If you are comfortable with Android Studio, create a new project and add the following to the AndroidManifest.xml:
<application ...>
<activity android:name=".MainActivity"
android:label="Kiosk"
android:exported="true"
android:lockTaskMode="if_whitelisted">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".MyDeviceAdminReceiver"
android:permission="android.permission.BIND_DEVICE_ADMIN"
android:exported="true">
<meta-data android:name="android.app.device_admin"
android:resource="@xml/device_admin_receiver" />
</receiver>
</application>
Also create res/xml/device_admin_receiver.xml with the standard device‑admin declaration. Build the APK and keep the package name handy (e.g., com.example.kiosk).
.apk to the same folder as your adb binary.adb install -r com.example.kiosk.apk. The -r flag allows reinstalling without wiping data.Success in the terminal).Only a freshly‑provisioned device (factory‑reset) can accept a new device owner. If the device already has a user profile, you must factory‑reset it first (Settings > System > Reset > Erase all data). After the reset, skip the initial setup screens until you reach the “Add Google Account” step, then press Back to skip it – this leaves the device in a “setup mode” that accepts a device‑owner command.
adb shell dpm set-device-owner com.example.kiosk/.MyDeviceAdminReceiver.Success: Device owner set, the app is now the device owner.Why this matters: The device‑owner status grants the app privileged APIs, including the ability to lock the screen into a single app.
Even as a device owner, Android requires you to explicitly permit which packages may enter lock task mode.
adb shell dpm set-lock-task-packages com.example.kiosk com.example.kiosk.adb shell dpm get-lock-task-packages com.example.kiosk. The output should list your package name.Now start the app and tell it to lock itself. The simplest way is to add the following line to the activity’s onCreate() method:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
startLockTask();
}
If you cannot modify the source code (e.g., you are using a third‑party kiosk app), you can trigger lock task from ADB:
adb shell monkey -p com.example.kiosk -c android.intent.category.LAUNCHER 1adb shell am start -n com.example.kiosk/.MainActivity --ez "android.intent.extra.LOCK_TASK" true (some apps expose a custom intent; check the developer docs).When the call succeeds, the navigation bar disappears, the status bar is hidden, and the device cannot exit the app without an admin command.
If any of these actions break out of the app, double‑check that the package is correctly whitelisted and that startLockTask() was called after the activity is fully resumed.
dpm set-device-owner command.dpm command.adb logcat | grep dpm for more details.adb shell am stopservice -n com.example.kiosk/.MyDeviceAdminReceiver or simply reboot the device.stopLockTask() after verifying a PIN.dpm command immediately.Setting a device owner gives the app full control over the device. Only use this on devices you intend to lock down permanently. Removing the device owner requires a factory reset, which erases all user data.
Screen pinning is safe for occasional use but should not replace a proper device‑owner kiosk when the device is publicly accessible.
With screen pinning you get a quick, user‑initiated lock that works on any Android phone. With lock‑task mode you obtain a true kiosk experience that can’t be escaped without administrative intervention. Choose the method that matches your security requirements, follow the steps above, and you’ll have a reliable, Android‑based kiosk without rooting or third‑party launchers.









