How can I get the cordova InAppBrowser to provide a way for the user to close the browser when using an Android device?

后端 未结 8 490
礼貌的吻别
礼貌的吻别 2020-12-13 04:57

I\'m using the cordova InAppBrowser to display content from an external site in my app. When I open the browser on an iPhone, there are some buttons at the bottom of the InA

8条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-13 05:25

    As stated by elMarquis, you need to add "location=yes" in order to get the "Done" button on an Android device. However, if you'd like to get the Done button by itself, without the address bar, it's fairly easy to do by making one change to the cordova source code.

    I got the information from this google group: https://groups.google.com/forum/?fromgroups=#!topic/phonegap/mUcBcjPISgg

    Here are some step-by-step instructions:

    1. Download the cordova source code:

      git clone https://github.com/apache/cordova-plugin-inappbrowser

    2. Download the commons codec lib from here

    3. Open Android Developer Tools
    4. Import the cordova project into your workspace

      File > Import... > Existing Projects into Workspace

    5. Create a libs directory and copy the downloaded commons-codec-1.7.jar file into it.

    6. Add a gen folder to the project (required by the .classpath file, but not included in the git download since git doesn't allow empty folders)
    7. Go to Project > Build All. The project should build without errors.
    8. Open InAppBrowser.java and search for "toolbar.addView(edittext);" (line 468 in the cordova version I downloaded).
    9. Comment out that line.
    10. Build the project again.
    11. Copy the bin/cordova.jar file into whatever project you are using cordova in.

    Hopefully that helps someone else.

提交回复
热议问题