Run Android as Kiosk or Single Application Mode

If you are planning to roll out an android application on a tablet for public use. Then running it as a kiosk mode is preferred, we can also call SINGLE APPLICATION MODE.

To achieve it there are couple of ways:

  • Custom build ROM according to your needs. I have not tried my hands over it, as it seems to be time intensive.
  • SureLock from 42gears. It works great but one need to buy License (Single $49.99)
  • Code tweak. It’s not fool proof but can be helpful to run Android in Single Application mode

 

We will talk about “CODE TWEAK” method and guide how to achieve the same. Inside your application code make following changes

Manifest file:

1. Add this to your main activity . This will launch your application when home button is pressed.

<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>

2. Auto-start your application on Boot by listening to by listening to the android.intent.action.BOOT_COMPLETED. Add this line to your Manifest file

<uses-permission android:name=”android.permission.RECEIVE_BOOT_COMPLETED” />

 

3.  Inside the main Application tag. Add this receiver code like you add a new activity

<receiver android:name=”com.example.android.MyBroastcastReceiver”>
    <intent-filter>
        <action android:name=”android.intent.action.BOOT_COMPLETED” />
    </intent-filter>
</receiver>
 

4. Add a file to your “src/com/example/android/MyBroadcastReceiver.java” and add these lines

package com.example.android;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
 
public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent startServiceIntent = new Intent(context, <MAIN>.class);
        context.startService(startServiceIntent);
    }
}

 

Edit <MAIN> to the activity you wish to auto-boot.

 

5. Reboot your tablet/device and it should run in Auto-Boot  Single application mode. It may prompt for default home option to select between “Launcher” and “Your Application”. Select your application and tick the checkbox to make it default selection.

 

One can now browse only device settings and run your application. To exit and run Android Launcher, go to Settings->apps->your application and “Clear Defaults”. Pressing the home button will again prompt for default  home option select Launcher this time and you can access the Android default launcher. I have tested on Android 4.0.3 and it’s working smooth.

 

Ideas/suggestions are welcome.