diff --git a/src/MobileApps/MyDriving/MyDriving.UWP/MyDriving.UWP.csproj b/src/MobileApps/MyDriving/MyDriving.UWP/MyDriving.UWP.csproj index f1e5c9c4..0ad4b6a7 100644 --- a/src/MobileApps/MyDriving/MyDriving.UWP/MyDriving.UWP.csproj +++ b/src/MobileApps/MyDriving/MyDriving.UWP/MyDriving.UWP.csproj @@ -400,7 +400,7 @@ Visual C++ 2015 Runtime for Universal Windows Platform Apps - + SQLite for Universal Windows Platform diff --git a/src/MobileApps/MyDriving/MyDriving.UWP/Views/CurrentTripView.xaml.cs b/src/MobileApps/MyDriving/MyDriving.UWP/Views/CurrentTripView.xaml.cs index 90c74ea6..a6e603d4 100644 --- a/src/MobileApps/MyDriving/MyDriving.UWP/Views/CurrentTripView.xaml.cs +++ b/src/MobileApps/MyDriving/MyDriving.UWP/Views/CurrentTripView.xaml.cs @@ -184,28 +184,38 @@ private async Task BeginExtendedExecution() ClearExtendedExecution(); - var newSession = new ExtendedExecutionSession + try { - Reason = ExtendedExecutionReason.LocationTracking, - Description = "Tracking your location" - }; - newSession.Revoked += SessionRevoked; - ExtendedExecutionResult result = await newSession.RequestExtensionAsync(); - switch (result) - { - case ExtendedExecutionResult.Allowed: - session = newSession; - ViewModel.Geolocator.AllowsBackgroundUpdates = true; - ViewModel.StartTrackingTripCommand.Execute(null); + var newSession = new ExtendedExecutionSession + { + Reason = ExtendedExecutionReason.LocationTracking, + Description = "Tracking your location" + }; + newSession.Revoked += SessionRevoked; + ExtendedExecutionResult result = await newSession.RequestExtensionAsync(); + switch (result) + { + case ExtendedExecutionResult.Allowed: + session = newSession; + ViewModel.Geolocator.AllowsBackgroundUpdates = true; + ViewModel.StartTrackingTripCommand.Execute(null); - break; + break; - default: - Acr.UserDialogs.UserDialogs.Instance.Alert("Unable to execute app in the background.", - "Background execution denied.", "OK"); + default: + Acr.UserDialogs.UserDialogs.Instance.Alert("Unable to execute app in the background.", + "Background execution denied.", "OK"); - newSession.Dispose(); - break; + newSession.Dispose(); + break; + } + } + catch (Exception ex) + { + // Sometimes while creating ExtendedExecution session you get Resource not ready exception. + Logger.Instance.Report(ex); + Acr.UserDialogs.UserDialogs.Instance.Alert("Will not be able to execute app in the background.", + "Background execution session failed.", "OK"); } }