This is the way I handle it (for years now). Similar to above. Method placed in a shared code module.
I call SetOro in each resume of every activity.
The assumption is that any screen size less than 6 (change if you want) is a phone - otherwise it is a tablet.
Another assumption is that phones will
always be used in
portrait mode (most reasonable) and tablets will be used in landscape mode (most practical). For my apps, this is the rule that I enforce. Took me quite some time to figure out the evils of device rotation - but now I know better.
The return boolean value let's me determine what size of device is in use - and I adjust text size accordingly (larger text size on tablets).
I also use lv.scale to determine device density (DPI) to adjust text size....
For example, in real world use, one of my apps runs on tablets, affixed to vehicles, locked into a powered cradle - in a landscape position.
All activities need to be shown in landscape mode - all the time.
Without this method, due to vibration or tilt/slant of vehicle, the mode would sometimes flip to portrait.
Locking the orientation on every (many) activity fixed this issue.
' Code module...
' Subs in this code module will be accessible from all modules.
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public oro As Phone
Public lv As LayoutValues
End Sub
Sub SetOro As Boolean
lv = GetDeviceLayoutValues
Dim ret As Boolean = False
Log(" Screen Size: "&lv.ApproximateScreenSize)
If lv.ApproximateScreenSize < 6 Then
oro.SetScreenOrientation( 1 ) ' port
Else
oro.SetScreenOrientation( 0 ) ' land
ret = True
End If
Return ret
End Sub