Android bar and advertising

Hello everyone.

In my game I do this:

if( platform == "Android" ) then local androidVersion = string.sub( system.getInfo( "platformVersion" ), 1, 3) if( androidVersion and tonumber(androidVersion) \>= 4.4 ) then native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) --native.setProperty( "androidSystemUiVisibility", "lowProfile" ) elseif( androidVersion ) then native.setProperty( "androidSystemUiVisibility", "lowProfile" ) end end

This works perfectly.

But there is a problem if a user sees an advertising video. In fact, when the video ends, the bar becomes visible again.

Do I have to invoke that code to remove the bar every time after a video or is there another way?

If the publicity creates a suspend event for the app I could also use a runtime listener. What do you recommend?

You will need to run that code again after the ad closes.  Use the onResize() event

In this way?

local function onResize( event ) if( platform == "Android" ) then local androidVersion = string.sub( system.getInfo( "platformVersion" ), 1, 3) if( androidVersion and tonumber(androidVersion) \>= 4.4 ) then native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) --native.setProperty( "androidSystemUiVisibility", "lowProfile" ) elseif( androidVersion ) then native.setProperty( "androidSystemUiVisibility", "lowProfile" ) end end end Runtime:addEventListener( "resize", onResize )

Yes that is what I do

Thanks so much! :slight_smile:

Wait what do you use that for???

Here is a safer way to hide the bar:

https://forums.coronalabs.com/topic/71593-got-message-from-android-developer-support-team-freeze-2-wont-run-on-upcoming-releases-of-android/?hl=androidsystemuivisibility#entry374709 

Thank you @sirmania and sorry for the delay.

I’m just a little confused…

function myResizeViewport() if (system.getInfo("platformName") == "Android") then if (system.getInfo("androidApiLevel") \>= 19) then native.setProperty("androidSystemUiVisibility", "immersiveSticky") else native.setProperty("androidSystemUiVisibility", "lowProfile") end end end

so the best method at the moment is this is not the previous one right?

yes use API level to support Android 9 - not yet a thing but hey

Thank you for the immediate clarifying!  @SGS

Yes we do not need it yet but better to stay in front if possible

For those who had the same problem in the end this is the best thing at the moment:

local platform = system.getInfo('platformName') if( platform == "Android" ) then local function onResize( event ) if (system.getInfo("androidApiLevel") \>= 19) then native.setProperty("androidSystemUiVisibility", "immersiveSticky") else native.setProperty("androidSystemUiVisibility", "lowProfile") end end Runtime:addEventListener( "resize", onResize ) end

I guees it should be:

local platform = system.getInfo('platform') 

instead of platformName which is deprecated.

You will need to run that code again after the ad closes.  Use the onResize() event

In this way?

local function onResize( event ) if( platform == "Android" ) then local androidVersion = string.sub( system.getInfo( "platformVersion" ), 1, 3) if( androidVersion and tonumber(androidVersion) \>= 4.4 ) then native.setProperty( "androidSystemUiVisibility", "immersiveSticky" ) --native.setProperty( "androidSystemUiVisibility", "lowProfile" ) elseif( androidVersion ) then native.setProperty( "androidSystemUiVisibility", "lowProfile" ) end end end Runtime:addEventListener( "resize", onResize )

Yes that is what I do

Thanks so much! :slight_smile:

Wait what do you use that for???

Here is a safer way to hide the bar:

https://forums.coronalabs.com/topic/71593-got-message-from-android-developer-support-team-freeze-2-wont-run-on-upcoming-releases-of-android/?hl=androidsystemuivisibility#entry374709 

Thank you @sirmania and sorry for the delay.

I’m just a little confused…

function myResizeViewport() if (system.getInfo("platformName") == "Android") then if (system.getInfo("androidApiLevel") \>= 19) then native.setProperty("androidSystemUiVisibility", "immersiveSticky") else native.setProperty("androidSystemUiVisibility", "lowProfile") end end end

so the best method at the moment is this is not the previous one right?

yes use API level to support Android 9 - not yet a thing but hey