"Kiosk" mode with OF

Seems to be usually very tricky… I need to use some android devices in kiosk mode -> once launched the user would not be able to leave the app.
It does not matter if the app have to be launched “manually” (would be better if it launch automatically at boot time but this is not that important)

I searched in the OF forums and on the net but I still don’t fully understand how to do…

Any hint ?

Thanks !

As a side note, the ideal solution would run on latest Amazon Kindle Fire 5, because those tablets are very cheap and more affordable for artists. The problem beeing that Amazon uses a custom Android system, may be more restrictive on what the user OR an app can do

It can be done with native android code and I am sure there is a way to do this from OF, but you can also look on the play store, there are a few apps that will be able to restrict your device to kisok mode.

You can’t do it (AFAIK) by just writing some code in the ofApp class, but you should be able to hack your way into an application with that behavior. You’ll need to modify OFActivity.java class and AndroidManifest.xml to implement the necessary restrictions. This is actually an Android issue and not OF issue.

Notice that you could also change main_layout.xml and add some native android controls to the activity. Here’s a good guide on creating an android kiosk mode: http://www.andreas-schrade.de/2015/02/16/android-tutorial-how-to-create-a-kiosk-mode-in-android/

Haven’t tried it but it looks descent. Good luck.

Thanks for your answers…

Fresla : I’ve tested some of them, found only one that seems to work on a Kindle 5 but it is restricted of some kind of web browsing only (and I want to restrict it to an app), and the license cost is 50$ per device

Tallavi : I tried to follow the guide you provided - I’m not very comfortable with Java development - I added the required new Java classes from the guide but at some point it seems that the default OfApp behaviour needs to be modified which is far beyond my skills :wink:

The guide’s author declare its app class like this

public class AppContext extends Application {

	private AppContext instance;
	private PowerManager.WakeLock wakeLock;
	private OnScreenOffReceiver onScreenOffReceiver;

	public void onCreate() {
		instance = this;

	private void startKioskService() { // ... and this method
		startService(new Intent(this, KioskService.class));

	private void registerKioskModeScreenOffReceiver() {
		// register screen off receiver
		final IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF);
		onScreenOffReceiver = new OnScreenOffReceiver();
		registerReceiver(onScreenOffReceiver, filter);

	public PowerManager.WakeLock getWakeLock() {
		if (wakeLock == null) {
			// lazy loading: first call, create wakeLock via PowerManager.
			PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
			wakeLock = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK
					| PowerManager.ACQUIRE_CAUSES_WAKEUP, "wakeup");
		return wakeLock;


I really wonder how this code can be plugged in OF android…

This code is completely orthogonal to what OF is doing. This code is plugged into your “empty example OF app” by adding the class and declaring this class as the application class in AndroidManifest.xml. OF doesn’t touch this part at all. OF starts working when the OFActivity class is created and comes to the foreground. OFActivity is the android part that hosts the openGL view that does the drawing you do in the cpp part. This will still happen as usual (because the OFActivity is already defined as the initial activity when the app is started). Notice that in the guide there are also steps that require changing the activity (handling the different buttons like home and recents). You will need to change the existing OFActivity.java class.

And regarding required java skills. Even though OF usually abstracts java/android stuff away from you and you can create apps by just modifying the cpp side, what you are trying to achieve is very much at the java part, so I see no way around it (other than if you or someone else will pick up the towel and build android kiosk mode directly into OF core). So if you want to brush up on relevant parts of android, I would start on the page about the activity class, especially the methods that are being overridden in the guide.

Good luck!

Thanks for these explanations !! Yes, I already modified the OFActivity.java file, and created the two other classes, one being the new App itself…

Seems a little more clear now :smile: