Android Tutorial Device Owner / TaskLock / Kiosk apps 2017

Not open for further replies.

Starting from Android 5 (API 21) there is better support for kiosk applications.
Kiosk applications = applications that the user cannot exit from.
As you can see in this screenshot, the home button and recent apps button are missing. The top notifications drawer is also inaccessible.

This solution is good for devices that serve a specific purpose. For example point of sale solutions or tourist information stands.

Device Owner App

1. The first step is to create an app and provision it as the device owner app. Download the attached example, change its package name to any value you like and run it on the device in Release mode.

2. Connect the device to the PC in USB debug mode. Open command line and run the following command:
Replace with the correct package name.
adb shell dpm set-device-owner


Existing user accounts on the device must first be removed (Settings - Accounts).

3. Add this code to the manifest editor (it is already there in the example project):
AddApplicationText(<receiver android:name="anywheresoftware.b4a.objects.AdminReceiver2"
  <meta-data android:name=""
  android:resource="@xml/device_admin" />
  <action android:name="" />
CreateResource(xml, device_admin.xml,
<device-admin xmlns:android="">
  <limit-password />
  <reset-password />
  <force-lock />

4. See how the example code locks and unlocks the activity.

Note that for the solution to be more robust it is recommended to make the activity a home launcher activity.

This is done by adding this code to the manifest editor:
  <action android:name="android.intent.action.MAIN" />
  <category android:name="android.intent.category.HOME" />
  <category android:name="android.intent.category.DEFAULT" />

With this code you need to click on the home button once and then you will be asked to choose the home launcher app. Choose your app.
This is important to make sure that your app starts as soon as possible after a restart.
During development you might prefer to disable it.

It depends on Administrator library v1.1+:


    8.6 KB · Views: 2,328


Licensed User
Longtime User
Hi there...

a. is it possible to load an app from the kiosk app (that actually) will be the foreground service that will load the kiosk app every min (like Erel said).. ? how ?
b. is it possible to load some app like google maps, IGO, Sygic from kiosk app and how ?



Licensed User
Longtime User
@Erel I ve understand about Intent but my question is someway different...

Actually i want the kiosk app stay alive - so before some posts you said that is better run another app too like a service to run kiosk app... That app will be running before kiosk app ?

Because if it is running after from kiosk app first i must unlock the app and then running the service-sticky-app (will be running the kiosk app)...

So from your post i ve understand will be the second answer - right ?

John Decowski

Licensed User
Longtime User
Is there a way with this method to dock your app on the top while launch another app? Reason being I want to Make an app for my motorcycle with a gauge set on top and nav on bottom ie. google or Waze
Not open for further replies.