From 4d9e4884dd485203804fcc53091c6567cc987fda Mon Sep 17 00:00:00 2001 From: sgrebnov Date: Thu, 28 Jan 2016 12:35:53 +0300 Subject: [PATCH] CB-10456 InAppBrowser is not closed if I close it programmatically on Android guthub close #143 --- src/android/InAppBrowser.java | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 256c064..a3b4a0d 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -362,15 +362,16 @@ public class InAppBrowser extends CordovaPlugin { * Closes the dialog */ public void closeDialog() { - final WebView childView = this.inAppWebView; - // The JS protects against multiple calls, so this should happen only when - // closeDialog() is called by other native code. - if (childView == null) { - return; - } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { + final WebView childView = inAppWebView; + // The JS protects against multiple calls, so this should happen only when + // closeDialog() is called by other native code. + if (childView == null) { + return; + } + childView.setWebViewClient(new WebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(WebView view, String url) { @@ -383,16 +384,16 @@ public class InAppBrowser extends CordovaPlugin { // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); + + try { + JSONObject obj = new JSONObject(); + obj.put("type", EXIT_EVENT); + sendUpdate(obj, false); + } catch (JSONException ex) { + Log.d(LOG_TAG, "Should never happen"); + } } }); - - try { - JSONObject obj = new JSONObject(); - obj.put("type", EXIT_EVENT); - sendUpdate(obj, false); - } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); - } } /**