From a37079596fb749cb6a0ee2add22c4e3bc93c5668 Mon Sep 17 00:00:00 2001 From: Emmanuel Hansen Date: Wed, 20 Nov 2024 21:01:32 +0000 Subject: [PATCH] don't check if intent is declared by app before launch (#17571) --- src/Android/Avalonia.Android/Platform/AndroidLauncher.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Android/Avalonia.Android/Platform/AndroidLauncher.cs b/src/Android/Avalonia.Android/Platform/AndroidLauncher.cs index 4aa793ee858..f3f69e344d4 100644 --- a/src/Android/Avalonia.Android/Platform/AndroidLauncher.cs +++ b/src/Android/Avalonia.Android/Platform/AndroidLauncher.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Android.Content; +using Android.OS; using Avalonia.Android.Platform.Storage; using Avalonia.Platform.Storage; using AndroidUri = Android.Net.Uri; @@ -15,20 +16,23 @@ public AndroidLauncher(Context context) { _context = context; } - + public Task LaunchUriAsync(Uri uri) { _ = uri ?? throw new ArgumentNullException(nameof(uri)); if (uri.IsAbsoluteUri && _context.PackageManager is { } packageManager) { var intent = new Intent(Intent.ActionView, AndroidUri.Parse(uri.OriginalString)); - if (intent.ResolveActivity(packageManager) is not null) + + try { var flags = ActivityFlags.ClearTop | ActivityFlags.NewTask; intent.SetFlags(flags); _context.StartActivity(intent); return Task.FromResult(true); } + catch (ActivityNotFoundException) { } + catch (FileUriExposedException) { } } return Task.FromResult(false); }