I have an app that mostly uses Landscape but has one Portrait activity.
I need to be able to set and freeze the orientation on a per activity basis.
I've tried Phone.SetScreenOrientation as described here but that does not lock the orientation and it still changes on a device rotation.
There is a thread that describes how to do this (how to lock orientation during runtime) and it seems like it would be a fit for Reflection but I don't have a good handle on Reflection semantics.
Is anyone willing to translate it for me or give me a pointer.
If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
p.SetScreenOrientation(0) 'landscape
Else
p.SetScreenOrientation(1) 'portrait
End If
so it just locks the orientation to whatever it was when the activity started.
No need for reflection or phone library, you can set each activity orientation using the manifest editor, let say you have 2 activities, Main and Extra:
I see why it did not work for me originally, the article I referenced used these constants.
' 1 = Portrait' 2 = Landscape' 9 = Reverse Portrait' 8 = Reverse Landscape
so I was doing p.SetScreenOrientation(2) to try and get landscape and that is now clearly wrong.
I used the SetActivityAttribute option and it works flawlessly.