From 7cba0de268288c6c17975f277cb04dc5fa8727a7 Mon Sep 17 00:00:00 2001 From: Craig Raw Date: Mon, 10 May 2021 08:42:50 +0200 Subject: [PATCH] check if opening uris is supported --- .../sparrowwallet/sparrow/AppServices.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sparrowwallet/sparrow/AppServices.java b/src/main/java/com/sparrowwallet/sparrow/AppServices.java index 2883c234..cfc3324c 100644 --- a/src/main/java/com/sparrowwallet/sparrow/AppServices.java +++ b/src/main/java/com/sparrowwallet/sparrow/AppServices.java @@ -601,14 +601,20 @@ public class AppServices { } public static void addURIHandlers() { - Desktop.getDesktop().setOpenURIHandler(event -> { - URI uri = event.getURI(); - if("bitcoin".equals(uri.getScheme())) { - Platform.runLater(() -> openBitcoinUri(uri)); - } else if("aopp".equals(uri.getScheme())) { - Platform.runLater(() -> openAddressOwnershipProof(uri)); + try { + if(Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.APP_OPEN_URI)) { + Desktop.getDesktop().setOpenURIHandler(event -> { + URI uri = event.getURI(); + if("bitcoin".equals(uri.getScheme())) { + Platform.runLater(() -> openBitcoinUri(uri)); + } else if("aopp".equals(uri.getScheme())) { + Platform.runLater(() -> openAddressOwnershipProof(uri)); + } + }); } - }); + } catch(Exception e) { + log.error("Could not add URI handler", e); + } } private static void openBitcoinUri(URI uri) {