I there something in B4i as the following code in B4A to check the screenorientation?
I know, that Page_Resize(Width As Int, Height As Int) gives the orientation, but I need to know, if the device is in right or left landscape.
In landscape, the heading of the device has always an 90° offset:
B4X:
Private Sub LocManager_HeadingChanged (MagneticHeading As Double, TrueHeading As Double)
B4X:
'B4A-Code:
Sub GetOrientation As Int
Dim r As Reflector
r.Target = r.GetContext
r.Target = r.RunMethod2("getSystemService", "window", "java.lang.String")
r.Target = r.RunMethod("getDefaultDisplay")
Return r.RunMethod("getOrientation")
End Sub
Sub DeviceOrientation As String
Dim no As NativeObject
Dim o As Int = no.Initialize("UIDevice").RunMethod("currentDevice", Null).RunMethod("orientation", Null).AsNumber
Select o
Case 0
Return "Unknown"
Case 1
Return "Portrait"
Case 2
Return "PortraitUpsideDown"
Case 3
Return "LandscapeLeft"
Case 4
Return "LandscapeRight"
Case 5
Return "FaceUp"
Case 6
Return "FaceDown"
End Select
Return "Unknown"
End Sub