This is a quick hit – if you’re using the InAppBrowser plugin in your PhoneGap app on Android you may want the child browser to display without the location bar and the included “close” button. The PhoneGap docs explain how to do this well enough, however Android’s back button is still functional. If you tap it enough you will eventually shutdown the child web view which may not be what you wanted to happen.

You could try to over-ride the default behavior by creating an event listener for the backbutton event but once InAppBrowser launches it handles the back button on its own. The backbutton event won’t fire until **after** the InAppBrowser child view has closed which of course is too late for our purposes.

An easy way to solve this is to just comment out the InAppBrowser function that handles the backbutton behavior. Locate in your project and search for a function called closeDialog. Once you locate it just wrap a c-style comment around the body of the function and save.

If in addition to preventing the web view from shutting down you also want to have the back button function like a web browser’s back button then you need to be a little more precise with your edit. As before, locate the closeDialog. It should look like the code sample below – note the changes:

  • Line 16: Comment out this line
  • Line 23: Comment out this line
  • Line 24: add the following: childView.goBack()
    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) {
        this.cordova.getActivity().runOnUiThread(new Runnable() {
            public void run() {
                childView.setWebViewClient(new WebViewClient() {
                    // NB: wait for about:blank before dismissing
                    public void onPageFinished(WebView view, String url) {
                if (dialog != null) {
                    //dialog.dismiss(); // COMMENT OUT THIS LINE
                // NB: From SDK 19: "If you call methods on WebView from any thread 
                // other than your app's UI thread, it can cause unexpected results."
                //childView.loadUrl("about:blank"); // <<< COMMENT OUT THIS LINE
	        childView.goBack(); // <<< ADD THIS LINE

        try {
            JSONObject obj = new JSONObject();
            obj.put("type", EXIT_EVENT);
            sendUpdate(obj, false);
        } catch (JSONException ex) {
            Log.d(LOG_TAG, "Should never happen");

This worked for me on my HTC One M8 - but, I'm not a Java Developer so please look at the above with a critical eye. Let me know in the comment section below if you have changes to whats here!