Kiosk mode for android

Mikhail Kim picture Mikhail Kim · Jul 8, 2014 · Viewed 7.6k times · Source

I have a hybrid application written on phonegap for android tablets. Now I want the tablet to show only my application. Basically I want the tablet to be always in kiosk mode running only my application. So that all the buttons are disabled. I have looked for solutions online and one of them is to use "surelock", but it doesnt do all of the above. Another option is to write my own ROM, however I couldnt find any good tutorials on that. Can anyone help me plz?

Answer

Mikhail Kim picture Mikhail Kim · Aug 21, 2014

I did a lot of research and now finally I am satisfied with what I got.

You basically have two options :

  1. Create you own custom ROM, which is not the best solution for me.

  2. Customize the tablets using various hacks.

So I will be explaining the second option.

First you need to root your devices. There are various methods, but I prefer rooting by oneclick software. For Chinese tablets you can use VROOT and for more popular ones use Kingo root.

Now, that you have your device rooted, we can get rid of the top and bottom bar.

private void hideBar(){
    try
    {
        Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 42 s16 com.android.systemui"}); 
        proc.waitFor();
    }
    catch(Exception ex)
    {
        Toast.makeText(getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
        Log.e("ROOT ERROR", ex.getMessage());
    }
}

This will make the top and bottom bar disappear. However you will probably need a way to show the bars again. For that you can use:

public void showBars(){
    try 
    {
        String command;
        command = "LD_LIBRARY_PATH=/vendor/lib:/system/lib am startservice -n com.android.systemui/.SystemUIService";
        String[] envp = null;
        Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command }, envp);
        proc.waitFor();
    } 
    catch(Exception ex)
    {
        Toast.makeText(context.getApplicationContext(), ex.getMessage(), Toast.LENGTH_LONG).show();
    }
}

Ok so we have that, all that remains is to make your application start at boot time. For that you can find many tutorials, just google.