我创建了一个非常简单的带有phonegap的移动应用程序,该应用程序与网络无关。所有资源(图像,CSS等)都是本地的,我不会对远程服务器进行任何ajax调用。但是当我检查手机上的移动数据屏幕时,我发现它已经使用了一些数据。请参阅下面的截图(第4个应用程序称为“cherouvim phonegap test”)。它说308KB,那是5小时。
点击它会给我以下细分:
HTML:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="user-scalable=no, width=device-width" />
<script type="text/javascript" src="phonegap.js"></script>
</head>
<body>
...
</body>
</html>
我使用phonegap构建,我的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 = "cherouvim.test"
version = "1.0.0">
<name>cherouvim phonegap test</name>
<description>...</description>
<preference name="phonegap-version" value="3.5.0" />
<preference name="android-installLocation" value="auto" />
<preference name="orientation" value="portrait" />
<preference name="fullscreen" value="true" />
<gap:plugin name="org.apache.cordova.media" />
<feature name="http://api.phonegap.com/1.0/network" />
<access origin="*" />
<gap:platform name="android" />
</widget>
在文档中说:
<!-- If you do not want any permissions to be added to your app, add the
following tag to your config.xml; you will still have the INTERNET
permission on your app, which PhoneGap requires. -->
<preference name="permissions" value="none"/>
这是否暗示Phonegap实际上在幕后做了网络相关的事情?
编辑:如果重要的话我正在使用nexus 5(android 4.4.4)并且我启用了“开发者模式”和ART运行时。
答案 0 :(得分:1)
使用“启用调试”选项集在phonegap构建中构建应用程序会在</body>
之前注入以下内容。
<script type="text/javascript" src="http://debug.build.phonegap.com/target/target-script-min.js#35fd7e24-189a-11e4-8c3c-e63707b18140"></script>
这用于phonegap build的weinre远程调试器。
没有“启用调试”选项的构建不会注入此远程脚本。因此,为生产使用而构建的应用程序实际上并不会像我最初想的那样使用任何移动数据。