From 0dff60f98ec47bde7d867b9da93c60fa106f768f Mon Sep 17 00:00:00 2001 From: dimitris Date: Thu, 4 Jun 2026 11:16:35 +0200 Subject: [PATCH] Guard external link launch against ActivityNotFoundException --- .../src/main/java/org/stendhalgame/client/ClientView.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/android/client/src/main/java/org/stendhalgame/client/ClientView.java b/app/android/client/src/main/java/org/stendhalgame/client/ClientView.java index 6bc105179b..d3bb03015a 100644 --- a/app/android/client/src/main/java/org/stendhalgame/client/ClientView.java +++ b/app/android/client/src/main/java/org/stendhalgame/client/ClientView.java @@ -14,6 +14,7 @@ package org.stendhalgame.client; import java.util.Random; import android.app.AlertDialog; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; @@ -189,7 +190,11 @@ public class ClientView extends WebView { if (!UrlHelper.isInternalUri(uri)) { // open external links in default browser/app // FIXME: should we ask for confirmation? - MainActivity.get().startActivity(new Intent(Intent.ACTION_VIEW, uri)); + try { + MainActivity.get().startActivity(new Intent(Intent.ACTION_VIEW, uri)); + } catch (final ActivityNotFoundException e) { + Notifier.toast("No app found to open this link"); + } return true; } view.loadUrl(UrlHelper.checkClientUrl(uri.toString()));