Android Code Snippet Detect Current Orientation

With reference to this thread:

https://www.b4x.com/android/forum/threads/detect-current-orientation.109829/

This sub will assist you to determine the current orientation of your activity.

I noticed that the solutions to this one on the forum are quite complicated or resource intensive. Here is a Sub you can use, which is very simple and uses minimal resources. Hope it helps someone.

B4X:
Sub DetermineCurrentScreenOrientation As String
 
    Dim orientation As String
 
    If Activity.Height > Activity.Width Then
        orientation = "portrait"
    Else
        orientation = "landscape"
    End If
 
    Return orientation
 
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…