Android Question How to set screenorientation programatically?

welu1805

Active Member
Licensed 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
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:

NJDude

Expert
Licensed User
You will have to create an option instructing the user to select the orientation and save it on a file, when the app starts, check the value of that flag and adjust the orientation accordingly.
 

welu1805

Active Member
Licensed 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
 
Top