Android Question Immersive Mode with Notch area working strange

Gunther

Active Member
Licensed User
Longtime User
Hello,

I have a question to:
https://www.b4x.com/android/forum/threads/immersive-mode-with-notch-area-support.100636/

The reason is because I am getting a gap when I start your app (small gap at the botton between the edge and the red line). Then I rotating to landscape (all fine = red lines at the edges). Also when I am rotating back to portrait.

I added "Log("SdK-Version: " & lv.Height & " 100%y " & 100%y & " 50dip " & 50dip" before and after the added code part.

B4X:
....
lv.Width = point.GetField("x")
        lv.Height = point.GetField("y")
        Log("SdK-Version: " & lv.Height & " 100%y " & 100%y  & " 50dip " & 50dip)
        '''Add android:windowLayoutInDisplayCutoutMode = never in manifest if you don't want to use notch area
        '''Add android:windowLayoutInDisplayCutoutMode = shortEdges in manifest if you want to use notch area
        Dim r As Rect
        r.Initialize(0,0,0,0)
        Dim WindowVisibleDisplayFrame As JavaObject = ctxt.RunMethodJO("getWindow", Null)
        WindowVisibleDisplayFrame = WindowVisibleDisplayFrame.RunMethodJO("getDecorView", Null)
        WindowVisibleDisplayFrame = WindowVisibleDisplayFrame.RunMethodJO("getWindowVisibleDisplayFrame",Array(r))
   
        If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
            Log(r)
            lv.Width = lv.Width - r.left
        Else
            Log(r)
            lv.Height = lv.Height - r.top
        End If
        Log("SdK-Version: " & lv.Height & " 100%y " & 100%y  & " 50dip " & 50dip)
....

B4X:
** Activity (main) Pause, UserClosed = true **
*** Activity_Pause ***
*** Activity_WindowFocusChanged ***
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
*** Activity_Create ***
*** GetRealSize ***
SdK-Version: 2220 100%y 2076 50dip 150
(Rect)(0, 72, 1080, 2076)
SdK-Version: 2148 100%y 2076 50dip 150 <---------First Start

** Activity (main) Resume **
*** Activity_Resume ***
*** Activity_WindowFocusChanged ***
** Activity (main) Pause, UserClosed = false **
*** Activity_Pause ***
** Activity (main) Create, isFirst = false **
*** Activity_Create ***
*** GetRealSize ***
SdK-Version: 1080 100%y 1080 50dip 150
(Rect)(0, 0, 2076, 1080)
SdK-Version: 1080 100%y 1080 50dip 150 <---------in landscape
** Activity (main) Resume **
*** Activity_Resume ***
*** Activity_WindowFocusChanged ***
** Activity (main) Pause, UserClosed = false **
*** Activity_Pause ***
** Activity (main) Create, isFirst = false **
*** Activity_Create ***
*** GetRealSize ***
SdK-Version: 2220 100%y 2076 50dip 150
(Rect)(0, 0, 1080, 2076)
SdK-Version: 2220 100%y 2076 50dip 150<---------back in portrait
** Activity (main) Resume **
*** Activity_Resume ***
*** Activity_WindowFocusChanged ***

You have any clue why it is correct only after a screen rotation?
 
Last edited:

Gunther

Active Member
Licensed User
Longtime User
Well, looks like an timing issue:

by adding a sleep(200) at the following location is gets the right figures in all of my resolutions:

B4X:
orientation.StartListening("orientation")
Sleep(200) <--------------------- added
Dim lv As LayoutValues = GetRealSize
Dim jo As JavaObject = Activity
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
SdK-Version: 1480 100%y 1384 50dip 100
(Rect)(0, 0, 720, 1384)
SdK-Version: 1480 100%y 1384 50dip 100
** Activity (main) Pause, UserClosed = false **
 
Upvote 0
Top