Phonegap Android InAppBrowser not working

穿精又带淫゛_ 提交于 2019-12-05 11:29:44

In Phonegap Cordova-3.0.0 version, for the app to communicate closely with various device-level features, we need to add plugins that provide access to core Cordova APIs.

The cordova plugin add command requires you to specify the repository for the plugin code. For example, In-app browser:

$ cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git

we need run this in command line. Don't need worries about AndroidManifest.xml or config.xml files. After you run $ cordova build, it will auto write for you.

You could get more idea about it in doc.phonegap

Add following code in config.xml this works fine for mi.

<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<access origin="*" browserOnly="true"/>

You have to mention the below code line in config.xml

<plugin name="InAppBrowser" value="CDVInAppBrowser" /> 

try to add this to your manifest, it helps me with a f*king plugin to work

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

try also not use 'plugin' tag in config.xml, but:

<feature name="InAppBrowser">
  <param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>

it will help for future updates of phonegap

Maan

To open a link in browser inside the app without opening external browser

HTML

<input type="button" id="button1" value = "click here"
       onclick="window.open('https://example.com','_blank','location=yes','closebuttoncaption = Return');">

Now go into your project folder and open Terminal or Command Prompt (Windows) and type the following command:

cordova plugin add cordova-plugin-inappbrowser --save

It will configure the required files and also add the plugin into your config.xml file.

Open your HTML page where you're trying to open the link, and put this JavaScript.

<script src="cordova.js"></script>
<script type = "text/javascript" charset = "utf-8">
function onLoad(){
    document.addEventlistner("deviceready", OnDeviceReady, false);
}

function onDeviceReady(){

}
</script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!