This StackOverflow question explores how to enable a device owner app, and thus kiosk mode, in the Android L developer preview. As the method requires a userdebug build of Android, rooting the device, and copying an XML file into the root filesystem, it doesn't seem suitable for mass deployment of a single function Android device inside a company.

How are device owner apps going to be installed on production Android L devices?


2 Answers 2


(Edit: Updated after some more testing)

Check the latest documentation.

This feature seems to be called Screen pinning now, and the App does not have to be the device owner. If the device owner is not set the user will be prompted to accept. But there are issues with this for kiosk use, mentioned below.

There are two ways to activate screen pinning:

Manually: Users can enable screen pinning in Settings > Security > Screen Pinning, and select the tasks they want to pin by touching the green pin icon in the recents screen. Programmatically: To activate screen pinning programmatically, call startLockTask() from your app. If the requesting app is not a device owner, the user is prompted for confirmation. A device owner app can call the setLockTaskPackages() method to enable apps to be pinnable without the user confirmation step.

If you activate screen pinning programatically (non device owner App) or on the device using the pin in the recents you get the following behaviour:

A dialog appears asking the user if they want to enable screen pinning and if they want to require a password to exit. If they press yes the status bar and notifications disappear, back, home and recents buttons do NOT disappear. Tapping on home or recents makes a toast appear inform the user how to exit screen pinning.

The user can then hold down back and recents to exit screen pinning. If the user selected to require a password, they will get kicked straight to the lock screen. This behaviour means it is not suitable for a kiosk imo. As it is too easy for kiosk users to end up looking at the lock screen.

To get a proper kiosk mode we need to set the device owner. Google's documentation says you need to do this with NFC:

To deploy and activate a device owner, you must perform an NFC data transfer from a programming app to the device while the device is in its unprovisioned state.

Using NFC to do this seems a bit complex (what if a device does not have NFC?). I have not investigated this yet so if anyone can provide info how you go about setting the device owner by NFC? Which now becomes the main point of your question. (i.e. setting the device owner on a non rooted device)

But to confirm the behaviour is as expected if you root a device you can set the device owner as per Google's previous instructions (adding a device_owner.xml) as I mentioned here

Now you can properly lock the App, no dialog appears for the user to accept, when enabled the recents and home button disappear and the user cannot leave the App unless your App unlocks itself. A proper kiosk mode. I have tested this on a Nexus 7 2013 with the latest Lollipop build.

The following snippet turns on the lock:

mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
mDeviceAdminSample = new ComponentName(this, DeviceAdminSample.class);

if (mDPM.isDeviceOwnerApp(this.getPackageName())) {
    Log.d(TAG, "isDeviceOwnerApp: YES");
    String[] packages = {this.getPackageName()};
    mDPM.setLockTaskPackages(mDeviceAdminSample, packages);
} else {
    Log.d(TAG, "isDeviceOwnerApp: NO");

if (mDPM.isLockTaskPermitted(this.getPackageName())) {
    Log.d(TAG, "isLockTaskPermitted: ALLOWED");
} else {
    Log.d(TAG, "isLockTaskPermitted: NOT ALLOWED");
  • I think this is the best possible answer available at the moment. The NFC step remains a mystery, but is a much narrower question.
    – Adrian Cox
    Oct 21, 2014 at 8:40
  • I have been trying to get the NFC step working but not had any success, I started a question on this here. Also There is a feature request with Google to improve the screen pinning for kiosk use here
    – tagy22
    Oct 21, 2014 at 9:06

I can't comment on an answer which is a bit of a nuisance but supplementary to tagy22's answer you can use dpm to set the device owner. More details here.

  • 1
    dpm would not get the job done if an account (such as Google account) is set in the device.
    – Firelord
    Sep 14, 2015 at 5:25
  • Will NFC in that case though? I was under the impression a device owner needed to be set prior to an account being added period. Sep 14, 2015 at 6:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .