Skip to content

Commit

Permalink
don't check if intent is declared by app before launch (#17571)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmauss authored and maxkatz6 committed Nov 26, 2024
1 parent 8f5d506 commit a370795
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Android/Avalonia.Android/Platform/AndroidLauncher.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,20 +16,23 @@ public AndroidLauncher(Context context)
{
_context = context;
}

public Task<bool> 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);
}
Expand Down

0 comments on commit a370795

Please sign in to comment.