As far as I am aware there is no official way to do this, as it could be used maliciously, but this is how I have achieved it. It works by rudely killing the system service that handles the Nav/Action bar etc. Crude but its the only thing that I could find that works.
This will block all of the navigation buttons, action bar etc. I'm not aware of a way to only stop one of these
hideNav() is called onCreate in the main activity, and showNav() is called from onDestroy, which you will need if you want a way for an admin to access the OS, as unless you specifically restart the service you will not be able to navigate around the device.
My app has an exit button that is only accessible with a password. The button calls getActivity().finish(), which you will need to invoke the onDestroy method of the activity.
NOTE: I've read that on some devices the systemui services is not always 42, so your tablet may need a different number in the command.
public void hideNav()
{
Log.v(tag, "hideNav");
try
{
Process p;
p = Runtime.getRuntime().exec("su");
// Attempt to write a file to a root-only
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("service call activity 42 s16 com.android.systemui\n");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
p.waitFor();
}
catch (Exception e)
{
Log.e(tag, "hideNav " + e.getMessage());
}
}
public void showNav()
{
Log.v(tag, "showNav");
try{
Process p;
p = Runtime.getRuntime().exec("su");
DataOutputStream os = new DataOutputStream(p.getOutputStream());
os.writeBytes("am startservice -n com.android.systemui/.SystemUIService\n");
// Close the terminal
os.writeBytes("exit\n");
os.flush();
p.waitFor();
}catch (IOException e) {
e.printStackTrace();
Log.e(tag, "showNav " + e.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
Log.e(tag, "showNav " + e.getMessage());
}
}