Guard external link launch against ActivityNotFoundException

This commit is contained in:
dimitris 2026-06-04 11:16:35 +02:00 committed by Jordan Irwin
parent 246d9ce288
commit 0dff60f98e

View file

@ -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()));