Search code examples
android-emulatormauiscreen-orientation

.NET MAUI always gives the original orientation even after changing the orientation on the Android emulator


This is kind of silly, but

private void OnButtonClicked(object sender, EventArgs e)
{
    Shell.Current.DisplayAlert("Orientaion", DeviceDisplay.Current.MainDisplayInfo.Orientation.ToString(), "OK");
}

always gives "portrait" (with a phone emulator) or "landscape" (with a tablet emulator) even after I switch the orientation. It just gives the default orientation even after the emulator successfully changes it.

What am I missing?


Solution

  • You can recheck if you have enabled option Auto-rotate on your Android device.

    Swipe down on your phone's screen, and then you will find the Auto-rotate option.

    Enter image description here