Xamarin android app restarting on orientation change with newer android versions

Felix Nogal 41 Reputation points


Our Xamarin android app is restarting whenever the device orientation is changed. We have configured the main activity with the following:

[Activity(Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]

This seems to work with older Android versions such us Andorid 9 but with Android 12/13 devices the app restarts on orientation changes.

Any ideas why this is not working on newer Android versions?

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,254 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 64,001 Reputation points Microsoft Vendor


    You can try to add ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize to your [Activity] attribute.

    Best Regards,

    Leon Lu

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful