/** * Close a custom browser screen. * * @return a PluginResult */ private synchronized PluginResult closeBrowser() { JSONObject obj = null; if (browser != null && browser.isDisplayed()) { uiApp.invokeAndWait( new Runnable() { public void run() { try { uiApp.popScreen(browser); } catch (IllegalArgumentException e) { Logger.log( ChildBrowser.TAG + ": Caught illegal argument exception: " + e.getMessage()); } } }); browser = null; obj = new JSONObject(); try { obj.put("type", CustomBrowser.CLOSE_EVENT); } catch (JSONException e) { return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } } return new PluginResult(PluginResult.Status.OK, obj); }