diff --git a/osu.Framework.Android/AndroidGameHost.cs b/osu.Framework.Android/AndroidGameHost.cs index a68b461da8..54a0c35dc5 100644 --- a/osu.Framework.Android/AndroidGameHost.cs +++ b/osu.Framework.Android/AndroidGameHost.cs @@ -82,18 +82,18 @@ public override void OpenUrlExternally(string url) if (!url.CheckIsValidUrl()) throw new ArgumentException("The provided URL must be one of either http://, https:// or mailto: protocols.", nameof(url)); - using (var intent = new Intent(Intent.ActionView, Uri.Parse(url))) + try { - // Recommended way to open URLs on Android 11+ - // https://developer.android.com/training/package-visibility/use-cases#open-urls-browser-or-other-app - try + using (var intent = new Intent(Intent.ActionView, Uri.Parse(url))) { + // Recommended way to open URLs on Android 11+ + // https://developer.android.com/training/package-visibility/use-cases#open-urls-browser-or-other-app gameView.Activity.StartActivity(intent); } - catch (ActivityNotFoundException e) - { - Logger.Error(e, $"Failed to start intent: {intent}"); - } + } + catch (Exception ex) + { + Logger.Error(ex, "Unable to open external link."); } } diff --git a/osu.Framework.iOS/IOSGameHost.cs b/osu.Framework.iOS/IOSGameHost.cs index 6a54592872..af41bf85c1 100644 --- a/osu.Framework.iOS/IOSGameHost.cs +++ b/osu.Framework.iOS/IOSGameHost.cs @@ -14,6 +14,7 @@ using osu.Framework.IO.Stores; using osu.Framework.iOS.Graphics.Textures; using osu.Framework.iOS.Graphics.Video; +using osu.Framework.Logging; using osu.Framework.Platform; using osu.Framework.Platform.MacOS; using UIKit; @@ -65,12 +66,19 @@ public override void OpenUrlExternally(string url) && !url.StartsWith("itms-beta://", StringComparison.Ordinal)) throw new ArgumentException("The provided URL must be one of either http://, https:// or mailto: protocols.", nameof(url)); - UIApplication.SharedApplication.InvokeOnMainThread(() => + try { - NSUrl nsurl = NSUrl.FromString(url).AsNonNull(); - if (UIApplication.SharedApplication.CanOpenUrl(nsurl)) - UIApplication.SharedApplication.OpenUrl(nsurl, new NSDictionary(), null); - }); + UIApplication.SharedApplication.InvokeOnMainThread(() => + { + NSUrl nsurl = NSUrl.FromString(url).AsNonNull(); + if (UIApplication.SharedApplication.CanOpenUrl(nsurl)) + UIApplication.SharedApplication.OpenUrl(nsurl, new NSDictionary(), null); + }); + } + catch (Exception ex) + { + Logger.Error(ex, "Unable to open external link."); + } } public override IResourceStore CreateTextureLoaderStore(IResourceStore underlyingStore) diff --git a/osu.Framework/Platform/DesktopGameHost.cs b/osu.Framework/Platform/DesktopGameHost.cs index a9c1674834..36e771de94 100644 --- a/osu.Framework/Platform/DesktopGameHost.cs +++ b/osu.Framework/Platform/DesktopGameHost.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using osu.Framework.Configuration; using osu.Framework.Extensions; +using osu.Framework.Logging; namespace osu.Framework.Platform { @@ -81,7 +82,14 @@ public override void OpenUrlExternally(string url) if (!url.CheckIsValidUrl()) throw new ArgumentException("The provided URL must be one of either http://, https:// or mailto: protocols.", nameof(url)); - openUsingShellExecute(url); + try + { + openUsingShellExecute(url); + } + catch (Exception ex) + { + Logger.Error(ex, "Unable to open external link."); + } } public override bool PresentFileExternally(string filename)