'True = Landscape, False = Portrait
Sub GetDefaultOrientation As Boolean
Dim context As JavaObject
context = context.InitializeStatic("anywheresoftware.b4a.BA").GetField("applicationContext")
Dim rotation As Int = context.RunMethodJO("getSystemService", Array As Object("window")) _
.RunMethodJO("getDefaultDisplay", Null).RunMethod("getRotation", Null)
Dim configOrientation As Int = context.RunMethodJO("getResources", Null).RunMethodJO("getConfiguration", Null) _
.GetField("orientation")
If ((rotation = 0 OR rotation = 2) AND configOrientation = 2) OR _
((rotation = 1 OR rotation = 3) AND configOrientation = 1) Then
Return True
Else
Return False
End If
End Sub