diff --git a/Xamarin.Essentials/DeviceInfo/DeviceInfo.android.cs b/Xamarin.Essentials/DeviceInfo/DeviceInfo.android.cs index d3d99c2e3..2e7520718 100644 --- a/Xamarin.Essentials/DeviceInfo/DeviceInfo.android.cs +++ b/Xamarin.Essentials/DeviceInfo/DeviceInfo.android.cs @@ -33,8 +33,15 @@ static DeviceIdiom GetIdiom() // first try UIModeManager using (var uiModeManager = UiModeManager.FromContext(Essentials.Platform.AppContext)) { - var uiMode = uiModeManager?.CurrentModeType ?? UiMode.TypeUndefined; - currentIdiom = DetectIdiom(uiMode); + try + { + var uiMode = uiModeManager?.CurrentModeType ?? UiMode.TypeUndefined; + currentIdiom = DetectIdiom(uiMode); + } + catch (Exception ex) + { + System.Diagnostics.Debug.WriteLine($"Unable to detect using UiModeManager: {ex.Message}"); + } } // then try Configuration