Kiosk mode in Android

Solution 1:

You can autostart applications on boot by listening to the android.intent.action.BOOT_COMPLETED intent in a BroadcastReceiver and start your Activity from there. In the Activity you can register yourself as the new default homescreen[1] and handle the keys.

I think there are some instances that you can't handle without modifying the framework (like longpress on Home to show currently active Applications) - I could also be mistaken though.

But for a prototype that could be sufficient.

Have fun tinkering!

[1]:

<intent-filter>
 <action android:name="android.intent.action.MAIN" />
 <category android:name="android.intent.category.HOME" />
 <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Solution 2:

You could customise this (disable access to menu, limit application addition etc) to enable kiosk. http://code.google.com/p/android-launcher-plus/

Solution 3:

In the new Android L Preview, Google has announced Task Locking, which does exactly that. It does seem to need root however.

The L Developer Preview introduces a new task locking API that lets you temporarily restrict users from leaving your app or being interrupted by notifications. This could be used, for example, if you are developing an education app to support high stakes assessment requirements on Android. Once your app activates this mode, users will not be able to see notifications, access other apps, or return to the Home screen, until your app exits the mode.

To prevent unauthorized usage, only authorized apps can activate task locking. Furthermore, task locking authorization must be granted by a specially-configured device owner app, through the android.app.admin.DevicePolicyManager.setLockTaskComponents() method.

To set up a device owner, follow these steps:

  • Attach a device running an Android userdebug build to your development machine.
  • Install your device owner app.
  • Create a device_owner.xml file and save it to the /data/system directory on the device.
$ adb root
$ adb shell stop
$ rm /tmp/device_owner.xml
$ echo "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>" >> /tmp/device_owner.xml
$ echo "&device-owner package=\"<your_device_owner_package>\" name=\"*<your_organization_name>\" />" >> /tmp/device_owner.xml
$ adb push /tmp/device_owner.xml /data/system/device_owner.xml
$ adb reboot

Before using the task locking API in your app, verify that your activity is authorized by calling DevicePolicyManager.isLockTaskPermitted().

To activate task locking, call android.app.Activity.startLockTask() from your authorized activity.

When task locking is active, the following behavior takes effect:

  • The status bar is blank, and user notifications and status information is hidden.
  • The Home and Recent Apps buttons are hidden.
  • Other apps may not launch new activities.
  • The current app may start new activities, as long as doing so does not create new tasks.
  • The user remains locked on your app until an authorized activity calls Activity.stopLockTask().