Bug? Possibly a bug with GetDeviceLayoutValues

Scantech

Well-Known Member
Licensed User
One thing i learned today is never get device dimensions in pause activity using GetDeviceLayoutValues. You better off passing it to LayoutValues in create event.

Here is the coding that you should never do in pause event. It should be True when at Portrait and then rotating. But it reports false. Technically, the layout has not been created for landscape mode when it was paused in Portrait and getting ready for landscape.

B4X:
Sub Activity_Pause (UserClosed As Boolean)

     Log(isPortraitLayout)
  
End Sub
B4X:
Sub isPortraitLayout() As Boolean
  
    If GetDeviceLayoutValues.Width <= GetDeviceLayoutValues.Height Then
        Log(GetDeviceLayoutValues.Width)
        Log(GetDeviceLayoutValues.Height)
        Log("True")
        Return True
    Else
        Log(GetDeviceLayoutValues.Width)
        Log(GetDeviceLayoutValues.Height)
        Log("False")
        Return False
    End If
End Sub
** Activity (main) Pause, UserClosed = false **
800
480
False
false
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
480
800
True
true
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
 

Erel

Administrator
Staff member
Licensed User
This is not a bug. GetDeviceLayoutValues gets the values directly from the OS. In this case the OS already reports the current screen size although the activity is not yet ready.

You should use 100%x and 100%y instead as you are interested in the activity dimensions.
 
Top