How to lock orientation of a device programmatically RRS feed

  • Question

  • User381646 posted

    I am testing my experimental launcher app, and using a customer button, I am trying to lock the orientation of the device by calling the following code: mainActivity.RequestedOrientation = ScreenOrientation.Locked; but it only works just for the launcher app. It does not change the lock on the orientation of the device as a whole. And if I open some other app, the orientation gets unlocked. Any solution /tips will be helpful.

    Friday, February 7, 2020 7:48 PM


  • User369978 posted

    It's impossible .

    You can only lock your application , but not the device .

    Android does not allow this permission to lock device in code , you can only lock it in settings manually.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Monday, February 10, 2020 2:27 AM