Book Image

Xamarin Mobile Application Development for Android, Second Edition

Book Image

Xamarin Mobile Application Development for Android, Second Edition

Overview of this book

Table of Contents (18 chapters)
Xamarin Mobile Application Development for Android Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Manually handling the orientation behavior


As described, the Android system automatically takes care of updating appropriate resources when the configuration changes. However, at times due to performance reasons, you might like to restrict the activity restart and write your own logic to update appropriate resources for the given configuration. But remember that this is not recommended by the Google guidelines; if you're implementing this for your application, do it at your own risk.

The following steps will guide you to manually handle the required configuration for your app:

  1. Add the ConfigurationChanges attribute to the activity declaration. This allows you to declare all possible configurations values defined in Android.Content.PM.ConfigChanges that you want to handle yourself for your app. At runtime, this adds the android:configChanges attribute to your activity declaration in the AndroidManifest.xml file:

    [Activity (Label = "POI List", ConfigurationChanges= ConfigChanges.Orientation ...