Android Question how determine device orientation when app starts

renzino

Member
Licensed User
Hello, when my app starts in portrait mode is displayed correctly, but if i put the device in landscape mode and launch the app, something get wrong, the splash screen is not displayed and some text in buttons are not setted, why? i forced orientation with "SetScreenOrientation(1)", but the problem remains....
 

ac9ts

Active Member
Licensed User
There's probably a lot wrong with my method but it seems to work.

B4X:
Sub GetOrientation As String

    Dim lv As LayoutValues 
    lv = GetDeviceLayoutValues
   
    If lv.Height > lv.Width Then
        Return "P"
    Else
        Return "L"
    End If
   
End Sub
 

Federico956

Member
Licensed User
There's probably a lot wrong with my method but it seems to work.

B4X:
Sub GetOrientation As String

    Dim lv As LayoutValues
    lv = GetDeviceLayoutValues
 
    If lv.Height > lv.Width Then
        Return "P"
    Else
        Return "L"
    End If
 
End Sub
I think that this code is enough, but I'm note sure:
B4X:
If 100%y > 100%x Then
    Return "P"
Else
    Return "L"
End If
EDIT: I've tried it and it works!
 
Top