Phonegap(在线版)应用程序 - 没有互联网连接和网络状态
我的第一个jQuery移动应用程序包含需要来自互联网来源的数据,如公共谷歌日历和亚马逊联盟小部件的元素,但它的工作只有当我在Chrome浏览器或Kindle Fire设备与html5应用程序测试者测试。
如果我建立android发布apk与在线Phonegap,Kindle和其他Android设备,如联想移动无法到达互联网连接的应用程序。我已经阅读了这个问题的所有主题,发现它建议使用< access origin =*subdomains =true/>
config.xml,但它是无效的。
我也把代码片段放在应用程序中,如:
My first jquery mobile app contains elements which needs datas from Internet sources like public Google calendars and Amazon affiliate widgets but it works only when I testing in my chrome browser or on a Kindle Fire device with the html5 app tester.
If I build android release apk with the online Phonegap, the Kindle and other android device like a Lenovo mobile can't reach the Internet connection in the app. I've read the all of topics in this issue and found the it was proposed to use <access origin="*" subdomains="true" />
in the config.xml but it was ineffective.
I also put code snippets in the app like:
if (navigator.onLine) {
$("#ifonline").append("Online");
} else {
$("#ifonline").append("offline");
}
var isOffline = 'onLine' in navigator && !navigator.onLine;
if ( isOffline ) {
$("#ifonline2").append("Status: offline");
}
else {
$("#ifonline2").append("online");
}
但结果是什么。我的config.xml:
But the result is nothing. My config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = "com.myapp.myapptodo"
versionCode = "10"
version = "1.0.0" >
<name>myapp</name>
<description>
myapp is very good but can't find that &@ĐäĐ wifi!
</description>
<author href="https://mysite" email="mymail">
Ceatos
</author>
<gap:plugin name="org.apache.cordova.network-information" />
<feature name="http://api.phonegap.com/1.0/geolocation"/>
<feature name="http://api.phonegap.com/1.0/media"/>
<feature name="http://api.phonegap.com/1.0/network"/>
<feature name="http://api.phonegap.com/1.0/notification"/>
<feature name="InAppBrowser">
<param name="android-package" value="org.apache.cordova.InAppBrowser"/>
</feature>
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
<access origin="*" subdomains="true" />
我有一个有效的wifi网络,设备连接到它。我该怎么办?
I have a working wifi network and the devices is connected to it. What should I do?
添加白名单插件
<gap:plugin name="cordova-plugin-whitelist" source="npm" />
您可能需要在头上添加此元标记
You might need to add this meta tag on the head
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src * 'unsafe-inline'; script-src * 'unsafe-inline'; media-src *">
并将这两行添加到config.xml
And add this two lines to the config.xml
<allow-navigation href="http://*/*" />
<allow-intent href="https://*/*" />