Phonegap Android InAppBrowser not working

2019-04-29 18:05发布

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>

5条回答
男人必须洒脱
2楼-- · 2019-04-29 18:29

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

<plugin name="InAppBrowser" value="CDVInAppBrowser" /> 
查看更多
贪生不怕死
3楼-- · 2019-04-29 18:30

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

查看更多
再贱就再见
4楼-- · 2019-04-29 18:34

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>
查看更多
仙女界的扛把子
5楼-- · 2019-04-29 18:35

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

查看更多
做个烂人
6楼-- · 2019-04-29 18:46

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

<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
<access origin="*" browserOnly="true"/>
查看更多
登录 后发表回答