Skip to content

Commit

Permalink
Try catch the uimode manager (xamarin#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno authored Jun 17, 2019
1 parent a12f14d commit f51d074
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Xamarin.Essentials/DeviceInfo/DeviceInfo.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f51d074

Please sign in to comment.