You can check the system setting from your MainActivity with this code:
bool rotationEnabled = Android.Provider.Settings.System.GetInt(ContentResolver, Android.Provider.Settings.System.AccelerometerRotation, 0) == 1;
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am implementing a Camera2 feature in our Xamarin Forms app. I'd like to know how to tell if the user has set their device to not allow rotations.
I can tell if it has been rotated. I'd like to know what the native setting is. Does it allow rotations. (I have read that Android allows us developers to over ride the native settings)
Thanks!
You can check the system setting from your MainActivity with this code:
bool rotationEnabled = Android.Provider.Settings.System.GetInt(ContentResolver, Android.Provider.Settings.System.AccelerometerRotation, 0) == 1;
Hello,
Welcome to Microsoft Q&A!
You can check if the device supports accelerometer
.
bool hasAccelerometer = PackageManager.HasSystemFeature(PackageManager.FeatureSensorAccelerometer);
Refer to https://stackoverflow.com/a/43093143/8187800 .
If the response is helpful, please click "Accept Answer" and upvote it.
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.