diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java index e7a377cfc..03a8c055f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/pebble/PebbleIoThread.java @@ -518,7 +518,7 @@ class PebbleIoThread extends GBDeviceIoThread { LOG.info("got GBDeviceEventAppManagement START event for uuid: " + appMgmt.uuid); if (prefs.getBoolean("pebble_enable_background_javascript", false)) { if (mPebbleProtocol.hasAppMessageHandler(appMgmt.uuid)) { - WebViewSingleton.disposeWebView(); + WebViewSingleton.stopJavascriptInterface(); } else { WebViewSingleton.runJavascriptInterface(gbDevice, appMgmt.uuid); } diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java index 2a1ad57de..d1af1ff83 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/util/WebViewSingleton.java @@ -197,6 +197,18 @@ public class WebViewSingleton { }); } + public static void stopJavascriptInterface() { + new Handler(webViewSingleton.mainLooper).post(new Runnable() { + @Override + public void run() { + if (webViewSingleton.instance != null) { + webViewSingleton.instance.removeJavascriptInterface("GBjs"); + webViewSingleton.instance.loadUrl("about:blank"); + } + } + }); + } + public static void disposeWebView() { if (internetHelperBound) { LOG.debug("WEBVIEW: will unbind the internet helper");