Phonegap Android InAppBrowser not working

蹲街弑〆低调 提交于 2020-01-02 04:45:40

问题


I am working on an Android App with Phonegap Cordova-3.0.0 and when I call InAppBrowser I got MotionEvent mTouchMode = 4 error. And InAppBrowser function is not working. So how can I fix this? Do I need do some setting on AndroidManifest.xml or config.xml? And I got this on my AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

And I got this on my config.xml

<plugins> <plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" /> </plugins>


回答1:


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




回答2:


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

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



回答3:


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

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



回答4:


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




回答5:


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>


来源:https://stackoverflow.com/questions/17849338/phonegap-android-inappbrowser-not-working

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