Android Immersive Mode and Unity3D

Today I got an email by one of the users of my mobile game STACK4 asking me to support the new “Immersive Fullscreen Mode”1 of the brand new Android 4.4 (KITKAT). To be honest I didn’t even know this feature was introduced. But it is actually pretty cool for mobile games, since it allows your app to use the fullscreen and to hide those softkeys that are shown in absence of hardware buttons. See the status bar and the softkeys on the photo, they are just moving in as an overlay when you swipe in on the top or bottom of the screen (which is a method first introduced on blackberry 10 devices)

Anyway it is not really difficult to implement when you already have an Android Plugin in Unity. So without much further ado, here is the Java code that you have to include into your UnityActivity in the onResume method:

protected void onResume() {
	if (Build.VERSION.SDK_INT >= 19) { //KITKAT
		int flagImmersiveSticky = 4096; //View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
		int flags = flagImmersiveSticky

There are a few things to mention about this:

  1. Why don’t I use the sdk identifiers2 for those new values ? Because Unity seems to refuse to build in my java plugin when it is not build against 4.2.2. Any ideas are welcome!
  2. Why in the onResume ? In onCreate it will work too, but whenever the app goes to the background and back to the front those settings seem to be reset either by android or unity, who knows.
  3. Why is there a “>=” in the if clause ? Because my code highlighting plugin in wordpress sucks 😀 Of course it is greater-or-equal.
  1. []
  2. new flags for immersive fullscreen in android sdk []

9 Comments on “Android Immersive Mode and Unity3D”

By JeReT. February 3rd, 2014 at 12:08 pm

which Android Plugin do you use?
thx in advance :)

By extrawurst. February 3rd, 2014 at 5:41 pm

When I was speaking about extending an existing Android Unity Plugin I was just talking about my own android plugin. But I guess any asset store plugin that comes with the source code will also do, since it must contain a class extending the UnityActivity too.
The Unity3d docs contains a pretty nice example on how to do that here:

By Charlotte. March 11th, 2014 at 3:46 am


I’m brand new to both Android development and javascript – I write all of my code in Unity3d with C#. Is there any chance you could give a link to a script/asset/etc. that would allow for the implementation of your code? I have no idea how to develop my own Android plugin and I’d really only want to use it to enter the “sticky immersive” mode anyway, so developping a full-fledged plugin when I’m sure one exists just seems pointlessly time consuming.

I’ve been googling stuff like “Android Unity”, “UnityActivity”, “sticky immersive unity”, etc. and the ONLY remotely useful page for my current knowledge level is this one.

Thanks if you can help out a bit more! :)

By Brandon. April 9th, 2014 at 6:57 am

So I’m trying to figure out how to implement this in my Unity game for Android.

I have experience in developing Android apps in Eclipse and have used Immersive Mode there, but I am lost when it comes to using Java code through plugins in Unity.

The only Android plugin that I am currently using is the official one for Google Play Game Services. Not sure if that one would work or not.

I’ve tried looking through the Unity docs for making a plugin but it seems over my head; I have never used JNI.

I guess what I’m asking is what class do I need to edit in an already existing Android plugin?

I’ll try messing around with what I have some more but you seem to be the only one talking about Immersive Mode with Unity!

Thanks for this post, users and developers appreciate it :)

By extrawurst. April 9th, 2014 at 10:21 am

The plugin you are using must be implementing a class X extending com.unity3d.player.UnityPlayerActivity like so:
public class X extends com.unity3d.player.UnityPlayerActivity {...}

In that class X you can place the code above to have immersive mode working.

Hope that helps.

By Brandon. April 9th, 2014 at 4:35 pm

Thanks Stephan, that should help me narrow down what to look for.

Reading through the Unity doc more, it looks like there are simpler ways to create plugins so I’ll give that a shot.

I also noticed that they said you can modify Unity’s own .jar files…I wonder if that could be done to avoid the need of creating a plugin.

Anyway, thanks again!

By JeReT. April 11th, 2014 at 2:03 pm

Hi Guys,

I figured out how to implement this. I did it a relatively complicated way with an eclipse project and stuff.

Meanwhile I found an article about how to implement a compass plugin for android with very little affort (which I couldn’t get running yet, but the way how to create the plugin works).
Here is the link:

hope this helps :)

By Brandon. April 12th, 2014 at 8:11 am

I edited the code directly into the onResume() function in file and it doesn’t work. App doesn’t crash or anything either…seems weird that it would have no effect.

Still working on trying to build a plugin I guess!

JeRet, that link was also a nice help, even though I haven’t got it figured out yet.

By Brandon. April 12th, 2014 at 9:00 am

Got it to work with a “simple” plugin I made by piecing together the posted guides, Unity docs and, of course, the code posted here!

Thanks for the help everyone. Once I get over the excitement and finally get some actual game coding done, I’ll post a link to the .jar and manifest file I made.

Leave a Reply