It is possible to catch the display orientation change event with agraham's SystemState library.
You will need to set an event for 'DisplayRotation' property.
Sub Globals
End Sub
Sub App_Start
Form1.Show
flb.New1("form1",B4PObject(1))
SysState.New1("DisplayRotation")
End Sub
Sub SysState_StateChanged 'This code will be fired when the orientation will chage.
form1.Show
textbox1.Text = SysState.CurrentValue 'will return 90 or 0 depending or the orientation.
End Sub
Sub Menu1_Click
AppClose
End Sub
Sub App_Start
flb.New1("landscape",B4PObject(1))
sysstate.New1("DisplayRotation")
End Sub
Sub SysState_StateChange
landscape.Show 'landscape is the name of the form
If (SysState.CurrentValue=270) Then landscape.Show 'run the form when landscape mode
If (SysState.CurrentValue=0) Then hardware.ShowTodayScreen 'run my app in background
End Sub
Exactly, except of the first line: lansdcape.show.
Sub SysState_StateChange
If SysState.CurrentValue=0 Then hardware.ShowTodayScreen
If SysState.CurrentValue=270 OR sysstate.currentValye = 90 Then Landscape.Show
End Sub
Please try to change the sub to:
B4X:Sub SysState_StateChange If SysState.CurrentValue=0 Then hardware.ShowTodayScreen If SysState.CurrentValue=270 OR sysstate.currentValye = 90 Then Landscape.Show End Sub
BTW, you should only upload source code and other image files. No need to upload dlls.
Sub Globals
lastOrientation = -1
End Sub
Sub App_Start
Form1.Show
flb.New1("form1",B4PObject(1))
SysState.New1("DisplayRotation")
hardware.New1
textbox1.Text = sysstate.CurrentValue
Timer1.Interval = 100
Timer1.Enabled = True
End Sub
Sub Timer1_Tick
newOrientation = SysState.CurrentValue
If newOrientation = lastOrientation Then Return
If newOrientation = 0 Then hardware.ShowTodayScreen
If SysState.CurrentValue=270 OR SysState.CurrentValue=90 Then form1.Show
lastOrientation = newOrientation
End Sub