1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Bug? Possibly a bug with GetDeviceLayoutValues

Discussion in 'Bugs & wishlist' started by Scantech, May 7, 2019.

  1. Scantech

    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.

    Code:
    Sub Activity_Pause (UserClosed As Boolean)

         
    Log(isPortraitLayout)
      
    End Sub
    Code:
    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
     
  2. Erel

    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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice