Android Question How to set screenorientation programatically?

welu1805

Active Member
Licensed User
Longtime User
My app can work with both orientations. But it should not be possible to change the orientation by moving the device.

The user can manually choose the orientation and saves it. At the next app start the app should use this screenorientation.

If the user changed the orientation the app should use the new orientation (or at the next start).

During runtime of the app the orientation should not can be changed by moving the device.

How can I do that?

Greetings
Lutz
 

Beja

Expert
Licensed User
Longtime User
Hi,
This question was asked before but can't remember where.. if you searched a little..
In general you need to compare the height and width of the activity.. if the height is bigger then it is in portrait.. (something like this).

Sorry misunderstanding.. I thought you are looking for getting the orientation, not setting it.
 
Last edited:
Upvote 0

welu1805

Active Member
Licensed User
Longtime User
Thank you,

now I know how to do:

Dim p as Phone

p.SetScreenOrientation(x)

x: -1 unspecified
x: 0 landscape
x: 1 portrait
 
Upvote 0
Top