Possible work-around to restore immersiveSticky mode

Hi,

As these threads mention …

https://forums.coronalabs.com/topic/53170-immersivesticky-and-displayscreenoriginx/

https://forums.coronalabs.com/topic/54351-problems-with-onsystemeventevent-and-immersivesticky/?hl=immersive

… apps can lose immersiveSticky mode under certain conditions.

A possible work-around is to not only re-set immersiveSticky mode, but to then use media.playVideo() to play a very short video clip.

This seems to (always?) force immersiveSticky back into effect.

The code is something like:

native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) media.playVideo( "shortVid.mp4", false )

The video clip is a one-second, all-black video I downloaded from youtube and trimmed to 0.10 seconds.

I’ve only tested it on my Android 5.0 device, but in all cases immersiveSticky is restored.

And visually, it’s not too jarring: the screen goes black for a split second, the navigation-bar flickers for another split-second and then slides off the screen.

NOTE: Playing a video causes “applicationSuspend”/“applicationResume” events, so if this is used in response to an “applicationResume” event,  a check needs to be made that the video was not just played else the app will enter an loop.

HTH,

David

That sounds a bit drastic!  I run my game fully immersive and don’t have any issues.

I use this to track any screen size changes.

local function onResize( event ) if (system.getInfo("platformName") == "Android") then local androidVersion = string.sub(system.getInfo("platformVersion"), 1, 3) if (androidVersion and tonumber(androidVersion) \>= 4.4) then native.setProperty("androidSystemUiVisibility", "immersiveSticky") elseif (androidVersion) then native.setProperty("androidSystemUiVisibility", "lowProfile") end end --do what is now needed to adapt to the screen size change end Runtime:addEventListener( "resize", onResize )

In my experience, whenever you display certain native objects (dialogs, video, et al) and/or suspend/resume an app you may encounter issues with the various android-visibility-modes.   This is highly dependent upon device and Android version.

In every case, you can resolve this by setting the visibility mode again at the right time:

  • one frame after resume event
  • one frame after closing video
  • one frame after closing dialog

fwiw, if you have a device (and they’re easy to find) which reproduces the “black bar when resume immersive sticky via task list” problem, then there is no combination of setting/resetting via native.setProperty that will correct it on its own, no matter the frame timing/delay after any system event (resume/resize/etc).  suspend + resume-via-app-icon will clear it though.

Try this
http://mobitutz.com/2017/01/24/start-up-guide/

I hope it helps.

Has anyone found any other workarounds for this? Arjorie’s link is broken – not sure what was in there.

I’m using DGuy’s workaround and showing a 0-second blank video, which works, but it does cause the screen to flicker black for a split second as he mentioned. I’m deciding what’s better between this or the black bar. Any other solutions?

I know it’s rooted in an Android bug, but other games seem to have worked around it somehow. It’s probably not very high on the priority list for Corona though.

Hi,

After a lot of research into the issue there is a hacky fix for this, which involved tearing apart the Dialog class to find. The navigation bar is shown when the dialog window is added to the Window Manager even if you set the UI visibility before adding it to the manager. 

// * Uses semi-transparent bars for the nav and status bars
// * This UI flag will *not* be cleared when the user interacts with the UI.
// When the user swipes, the bars will temporarily appear for a few seconds and then
// disappear again.

Hi Thomas,

Your post seems to be taken from the beginning of this Stack Overflow answer:

https://stackoverflow.com/questions/22794049/how-do-i-maintain-the-immersive-mode-in-dialogs/23207365#23207365

That thread deals with custom Android dialogs. Were you able to find a way to apply that fix to the case described here?

That sounds a bit drastic!  I run my game fully immersive and don’t have any issues.

I use this to track any screen size changes.

local function onResize( event ) if (system.getInfo("platformName") == "Android") then local androidVersion = string.sub(system.getInfo("platformVersion"), 1, 3) if (androidVersion and tonumber(androidVersion) \>= 4.4) then native.setProperty("androidSystemUiVisibility", "immersiveSticky") elseif (androidVersion) then native.setProperty("androidSystemUiVisibility", "lowProfile") end end --do what is now needed to adapt to the screen size change end Runtime:addEventListener( "resize", onResize )

In my experience, whenever you display certain native objects (dialogs, video, et al) and/or suspend/resume an app you may encounter issues with the various android-visibility-modes.   This is highly dependent upon device and Android version.

In every case, you can resolve this by setting the visibility mode again at the right time:

  • one frame after resume event
  • one frame after closing video
  • one frame after closing dialog

fwiw, if you have a device (and they’re easy to find) which reproduces the “black bar when resume immersive sticky via task list” problem, then there is no combination of setting/resetting via native.setProperty that will correct it on its own, no matter the frame timing/delay after any system event (resume/resize/etc).  suspend + resume-via-app-icon will clear it though.

Try this
http://mobitutz.com/2017/01/24/start-up-guide/

I hope it helps.

Has anyone found any other workarounds for this? Arjorie’s link is broken – not sure what was in there.

I’m using DGuy’s workaround and showing a 0-second blank video, which works, but it does cause the screen to flicker black for a split second as he mentioned. I’m deciding what’s better between this or the black bar. Any other solutions?

I know it’s rooted in an Android bug, but other games seem to have worked around it somehow. It’s probably not very high on the priority list for Corona though.

Hi,

After a lot of research into the issue there is a hacky fix for this, which involved tearing apart the Dialog class to find. The navigation bar is shown when the dialog window is added to the Window Manager even if you set the UI visibility before adding it to the manager. 

// * Uses semi-transparent bars for the nav and status bars
// * This UI flag will *not* be cleared when the user interacts with the UI.
// When the user swipes, the bars will temporarily appear for a few seconds and then
// disappear again.

Hi Thomas,

Your post seems to be taken from the beginning of this Stack Overflow answer:

https://stackoverflow.com/questions/22794049/how-do-i-maintain-the-immersive-mode-in-dialogs/23207365#23207365

That thread deals with custom Android dialogs. Were you able to find a way to apply that fix to the case described here?