PhoneGap New Window Inappbrowser Plugin

Source: Internet
Author: User

In the PhoneGap development process, you need to call external Web pages, but also out of whitelist security restrictions, you can use the Inappbrowser plugin.

Http://plugins.cordova.io/#/package/org.apache.cordova.inappbrowser

Use case:
http://blog.csdn.net/gapapp/article/details/17093601

The Inappbrowser plugin, as its name implies, is the app's built-in browser. When using the Inappbrowser plugin, the default phone return key is pressed to exit the built-in browser instead of the history fallback.

Workaround: Change two places

1, Org.apache.cordova.inappbrowser\src\android\inappbrowserdialog.java

Find the Onbackpressed method and change to the following

    public void onbackpressed () {        if (This.inappbrowser = = null) {            This.dismiss ();        } else {            //better to go t Hrough the Inappbrowser            //Because it does a clean up            if (This.inAppBrowser.canGoBack ()) {This.inAppBrowser.go Back ();}  else {this.inAppBrowser.closeDialog ();}        }    }

2, Org.apache.cordova.inappbrowser\src\android\inappbrowser.java

Find the GoBack method and change private to public

public void GoBack () {     if (This.inAppWebView.canGoBack ()) {         this.inAppWebView.goBack ();}     }

And then add a method

public Boolean cangoback () {return this.inAppWebView.canGoBack ();}

PhoneGap New Window Inappbrowser Plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.