Logo Icon Logo
A Crowd-sourced Cookbook on Writing Great Android® Apps
GitHub logo Twitter logo OReilly Book Cover Art

Alternate Home Screen (Kiosk Mode Phone)

In Chapter: Packaging, deploying and selling
Author: Ian Darwin ('idarwin')
Published? false
FormatLanguage: WikiFormat


You need to provide an alternate home screen for your phone.


Just add <category android:name="android.intent.category.HOME" /> to the Intent filter of your main application's main Activity. You don't even need any extraordinary permissions.


Making an application that can be installed as a Home Screen is simple; you just have to add the HOME intent category to the main Activity's intent filter.

   <activity android:name=".HomeActivity"
        android:label="@string/title_activity_home" >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />

When you install the application on a device, Android will notice that it is a Home Screen app. Just press the Home button, and you will be asked which home screen to use. The first one in this diagram is the default one, and the second is my HomeActivity app.

Note that if you select the "Use by default for this action" checkbox, you won't see the prompt again. If you then reboot the phone, your chosen app will run as the Home application.

"Kiosk mode" is a description that dates from the early days of the Web, when desktop browsers could be "locked down" so that a user could not escape to the operating system. The intent was to replicate with just a browser, the type of environment that previously required writing a carefully locked-down desktop application.

To make a "Kiosk mode" phone, you just have to either install your single app as the Home App, or, install a Home App that only allows the user to run applications of your choice, select it as the default home app as described above, and reboot it.

The sample app uses a ListView to display the name of some (the only) apps the user can run. There is a data structure containing the name and Intent for each app. The ListAdapter displays the name in the list (if you use it, please extend it to include the icon!). The onClick listener for the ListView simply starts the Intent.

    /** The allowed actions */
    MyAppDesc[] progs = {
            new MyAppDesc("Phone",
                new Intent(Intent.ACTION_DIAL, null)),
            new MyAppDesc("Web",            // XXX Grossly insecure kiosk!
                new Intent(Intent.ACTION_VIEW, Uri.parse("http://google.com"))),
     * The heart of the home app: run user's chosen other app.
    protected void onListItemClick(final ListView l, final View v, int position, long id) {

Security Warning

Obviously, if you take your Kiosk Mode seriously, you won't include any app that can open another Intent (like a browser), as it's then trivial for the user to break out by installing another home app and rebooting, which will give them a chance to choose the standard home app.

Note that this is not a very strong kiosk mode - a knowledgable user can delete your home app using ADB. If you remove the running Home app, Android will just reboot and fall back to using any other available home app, typically the default one. However, for non-malicious users, typically users that only need or want to run one application, this provides a usable kiosk mode.

See Also:

This version only works where the targets can be invoked by intent. If you needed to run a particular Unix/Linux application program by name, you'd want to use Runtime.exec() as described in 1365.


The source code for this project is in the Android Cookbook repository, http://github.com/IanDarwin/Android-Cookbook-Examples/tree/master/HomeAppListView.


If you found this recipe useful, why not buy the book and have the whole collection always at hand?"