在BlackBerry模拟器或者真机上高效测试WebWorks/PhoneGap程序--不需要重新打包编译

来源:互联网 发布:仁化网络问政 编辑:程序博客网 时间:2024/05/19 13:17

正常情况下,在BlackBerry手机上面每次修改了html/javascript以后,你需要打包项目为zip文件,使用WebWorks SDK编译zip文件为cod文件,然后部署到模拟器或者真机(还需要签名)进行测试。


这个,在开发调试的时候,有点烦人了。其实有更好的办法,摆脱打包/编译/签名的繁琐重复劳动。方法如下:

1)把cod文件里面的各种html等资源文件放在SD卡上,或者放在一个测试Web服务器上面;

2)让WebWorks应用的启动页面指向到SD卡或者测试Web服务器的页面;

3)放开WebWorks的安全控制。


编辑config.xml文件,编辑如下两行:

<content src="file:///SDCard/myTestFolder/index.html"/> 或者是 <content src="http://mytestsite.com/index.html" />

<access subdomains="true" uri="*" />


参考:

Update your BlackBerry WebWorks application without Recompiling


======================================================================

下面是我的测试应用使用的config.xml(参考自bbUI项目和PhoneGap BlackBerry模块)。

注意其中黄色部分,分别是指定启动页面的URL,禁用WebWorks的cache功能(否则修改了html,但是WebWorks里面显示的还是老的页面,程序调试好以后要把cache再次打开),开放所有URL资源访问权限给WebWorks应用。


<?xml version="1.0" encoding="utf-8"?>
<!--
* Copyright 2010-2011 Research In Motion Limited.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<widget xmlns="http://www.w3.org/ns/widgets"
        xmlns:rim="http://www.blackberry.com/ns/widgets"
    version="1.0.0.0">

  <rim:navigation mode="focus" />

  <name>WebWorksTDD Development</name>

  <rim:loadingScreen backgroundImage="images\background.png" foregroundImage="images\hippo.png" onFirstLaunch="true">
    <rim:transitionEffect type="fadeIn" />
  </rim:loadingScreen>

  <icon src="images\icon.png" />
  <icon src="images\icon.png" rim:hover="true" />

  <content src="http://shanghai.springworks.info/WebWorksTDD/index.html" />


  <!-- bbUI API -->
  <feature id="blackberry.push" />
  <feature id="blackberry.message.sms" />
  <feature id="blackberry.ui.menu" />
  <feature id="blackberry.identity" />
  <feature id="blackberry.system.event" />
  <feature id="blackberry.app" />

  <!-- PhoneGap API -->
  <feature id="blackberry.system" required="true" version="1.0.0.0" />
  <feature id="blackberry.find" required="true" version="1.0.0.0" />
  <feature id="blackberry.identity" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Address" required="true" version="1.0.0.0" />
  <feature id="blackberry.pim.Contact" required="true" version="1.0.0.0" />
  <feature id="blackberry.io.file" required="true" version="1.0.0.0" />
  <feature id="blackberry.utils" required="true" version="1.0.0.0" />
  <feature id="blackberry.io.dir" required="true" version="1.0.0.0" />
  <feature id="blackberry.app" required="true" version="1.0.0.0" />
  <feature id="blackberry.app.event" required="true" version="1.0.0.0" />
  <feature id="blackberry.system.event" required="true" version="1.0.0.0"/>
  <feature id="blackberry.widgetcache" required="true" version="1.0.0.0"/>
  <feature id="blackberry.media.camera" />
  <feature id="blackberry.ui.dialog" />

  <rim:cache disableAllCache="true" />
 
  <!-- PhoneGap API -->
  <access subdomains="true" uri="file:///store/home" />
  <access subdomains="true" uri="file:///SDCard" />

  <!-- Expose access to all URIs, including the file and http protocols -->
  <access subdomains="true" uri="*" />

  <rim:permissions>
    <rim:permit>use_camera</rim:permit>
    <rim:permit>read_device_identifying_information</rim:permit>
    <rim:permit>access_shared</rim:permit>
    <rim:permit>read_geolocation</rim:permit>
  </rim:permissions>

</widget>

======================================================================

测试中发现

1)用公网internet Web服务器,而且WebWorks禁用了cache,网络访问速度比较慢

2)用局域网intranet Web服务器,我的BlackBerry 9800是公司BES激活的,无法访问局域网Web服务器。解决办法:删除Service Book -- Desktop IPPP就不走MDS服务器,直接走WiFi访问局域网intranet Web服务器了。

原创粉丝点击