I have tried everything described in different threads related to Immersive Mode. In my case the layout is built through B4A code, not loaded.
The behavior is heretic.
The navigation bar is hidden, but the layout is sometimes resized, sometimes not.
I need to change the orientation one time in order to fill up the screen with the layout, but event then, controls are in the right position, but the drawing on the canvas is extended more than normal, on one direction.
My device is an LG G3 with Android 5.0.1.
This is what I have now:
Any idea how to make it work as expected?
Thanks.
The behavior is heretic.
The navigation bar is hidden, but the layout is sometimes resized, sometimes not.
I need to change the orientation one time in order to fill up the screen with the layout, but event then, controls are in the right position, but the drawing on the canvas is extended more than normal, on one direction.
My device is an LG G3 with Android 5.0.1.
This is what I have now:
B4X:
Sub Globals
Dim ActivityParent As JavaObject
...
End Sub
Sub ForceImmersiveMode
If Ph.SdkVersion >= 19 Then
' available flags:
' SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 4096 (0x01000)
' SYSTEM_UI_FLAG_IMMERSIVE = 2048 (0x0800)
' SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 1024 (0x0400)
' SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 512 (0x0200)
' SYSTEM_UI_FLAG_LAYOUT_STABLE = 256 (0x0100)
' SYSTEM_UI_FLAG_FULLSCREEN = 4 (0x04)
' SYSTEM_UI_FLAG_HIDE_NAVIGATION = 2 (0x02)
Dim flag As Int
flag = SYSTEM_UI_FLAG_IMMERSIVE_STICKY + SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + SYSTEM_UI_FLAG_FULLSCREEN + SYSTEM_UI_FLAG_HIDE_NAVIGATION ' 5894 (0x01706)
Dim r As Reflector
r.Target = r.GetActivity
r.Target = r.RunMethod("getWindow")
r.Target = r.RunMethod("getDecorView")
r.RunMethod2("setSystemUiVisibility", flag, "java.lang.int")
Dim ajo As Panel = Activity
Dim width As Int = ActivityParent.RunMethod("getMeasuredWidth", Null)
Dim height As Int = ActivityParent.RunMethod("getMeasuredHeight", Null)
If width = 0 Or height = 0 Then Return
ajo.Width = width 'update the "activity" width and height
ajo.Height = height
If pnlRxTx.IsInitialized Then
pnlRxTx.Width = width
pnlRxTx.Height = height
End If
End If
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim jo As JavaObject = Activity
jo.RunMethodJO("getContext", Null).RunMethodJO("getWindow", Null).RunMethod("setSoftInputMode", Array As Object(0x20))
ActivityParent = jo.RunMethodJO("getParent", Null)
ForceImmersiveMode
...
End Sub
Any idea how to make it work as expected?
Thanks.