Skip to content

Commit

Permalink
catch StartActivity for ShouldOverrideUrlLoading
Browse files Browse the repository at this point in the history
  • Loading branch information
trudyhood committed Jun 22, 2024
1 parent d2e9b28 commit 787d26c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions VpnHood.Client.App.Android.Common/AndroidAppWebViewClient.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Android.Content;
using Android.Webkit;
using Microsoft.Extensions.Logging;
using VpnHood.Common.Logging;

namespace VpnHood.Client.App.Droid.Common;

Expand All @@ -23,9 +25,16 @@ public override bool ShouldOverrideUrlLoading(WebView? webView, string? url)
if (uri.AbsolutePath == "/" || string.IsNullOrEmpty(uri.AbsolutePath))
return false;

var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(url));
intent.SetFlags(ActivityFlags.NewTask);
Application.Context.StartActivity(intent);
try
{
var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(url));
intent.SetFlags(ActivityFlags.NewTask);
Application.Context.StartActivity(intent);
}
catch (Exception ex)
{
VhLogger.Instance.LogError(ex, $"Could not launch any activity for {url}");
}

return true;
}
Expand Down

0 comments on commit 787d26c

Please sign in to comment.