tips:cordova:inappbrowser

This is an old revision of the document!


inAppBrowser

With these modifications the hardware back button works within pages in an InAppBrowser.

src/com/org/apache/corodova/inappbrowser/InAppBrowser.java

change

private void goBack() {
   if (this.inAppWebView.canGoBack()) {
      this.inAppWebView.goBack();
   }
}

to (note public method)

public void goBack() {
   if (this.inAppWebView.canGoBack()) {
      this.inAppWebView.goBack();
   }
}
 
public boolean canGoBack() {
   return this.inAppWebView.canGoBack();
}

src/com/org/apache/corodova/inappbrowser/InAppBrowserDialog.java change

public void onBackPressed () {
   if (this.inAppBrowser == null) {
      this.dismiss();
   } else {
      // better to go through the in inAppBrowser
      // because it does a clean up            
      this.inAppBrowser.closeDialog();           
   }
}

to

public void onBackPressed () {
   if (this.inAppBrowser == null) {
      this.dismiss();
   } else {
      if (this.inAppBrowser.canGoBack()) {
         this.inAppBrowser.goBack();
      }  else {
         this.inAppBrowser.closeDialog();
      }
   }
}
  • tips/cordova/inappbrowser.1424846044.txt.gz
  • Last modified: 2015/02/25 07:34
  • by scipio