This solution is only for services, especially widgets. Service modules do not have Activity_Resume.
After looking at a few suggestions to catch screen rotation in services, I decided to use the timer that I already had running at 1000ms cycles and variables in Globals.
I just thought I would share it with bit of code with forum users.
This is the best solution I could come up with to catch screen rotation in services. It works for me so I'm sticking with it
Thank you, I hope that this helps someone one day.
After looking at a few suggestions to catch screen rotation in services, I decided to use the timer that I already had running at 1000ms cycles and variables in Globals.
I just thought I would share it with bit of code with forum users.
B4X:
Sub Process_Globals
Dim CheckScrOrientation, StoredOrientation As String
Dim RotateTimer As Timer
End Sub
Sub Service_Start(StartingIntent As Intent)
RotateTimer.Initialize("SDTime", 500) '1000 Milliseconds = 1 second
RotateTimer.Enabled = True
End Sub
Sub SDTime_Tick
If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
CheckScrOrientation = "Landscape"
Else
CheckScrOrientation = "Portrait"
End If
If CheckScrOrientation <> StoredOrientation Then
StoredOrientation = CheckScrOrientation
'PUT WHATEVER UPDATE/REFRESH ROUTINE OR CALLSUB YOU NEED TO HERE...
End If
End Sub
Thank you, I hope that this helps someone one day.
Last edited: