Android Question How to set screenorientation programatically?

Discussion in 'Android Questions' started by welu1805, Apr 28, 2015.

  1. welu1805

    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?

  2. Beja

    Beja Expert Licensed User

    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: Apr 28, 2015
  3. NJDude

    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.
    thedesolatesoul, lemonisdead and Beja like this.
  4. welu1805

    welu1805 Active Member Licensed User

    Thank you,

    now I know how to do:

    Dim p as Phone


    x: -1 unspecified
    x: 0 landscape
    x: 1 portrait
    noeleon likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice