diff --git a/src/android/InAppBrowser.java b/src/android/InAppBrowser.java index 87df9d230..84144389f 100644 --- a/src/android/InAppBrowser.java +++ b/src/android/InAppBrowser.java @@ -313,7 +313,9 @@ else if (action.equals("show")) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { - dialog.show(); + if (dialog != null) { + dialog.show(); + } } }); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); @@ -324,7 +326,9 @@ else if (action.equals("hide")) { this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { - dialog.hide(); + if (dialog != null) { + dialog.hide(); + } } }); PluginResult pluginResult = new PluginResult(PluginResult.Status.OK); @@ -1065,12 +1069,14 @@ public void postMessage(String data) { lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; - dialog.setContentView(main); - dialog.show(); - dialog.getWindow().setAttributes(lp); + if (dialog != null) { + dialog.setContentView(main); + dialog.show(); + dialog.getWindow().setAttributes(lp); + } // the goal of openhidden is to load the url and not display it // Show() needs to be called to cause the URL to be loaded - if(openWindowHidden) { + if (openWindowHidden && dialog != null) { dialog.hide(); } }