[Phonegap+Sencha Touch] 移动开发2、PhoneGap/Cordova初步使用

原文地址:http://blog.csdn.net/lovelyelfpop/article/details/20392249


下面讲的是创建一个PhoneGap/Corodva项目,然后打包成apk安装包 的一般方法。与以后讲Sencha touch+PhoneGap/Corodva的开发有少许不同。

1、打开cmd,把盘符转到想要创建项目的目录,比如 
D:\


2、创建项目
运行命令:
phonegap create hello com.pushsoft.hello Hello
cordova create hello com.pushsoft.hello Hello
第一个hello是项目文件夹名,此处就是D:\hello,在此文件夹下会生成www子目录作为主页面存入目录,包括有css,js和img资源。 其中config.xml包括了重要的资源描述和项目配置信息.
com.pushsoft.hello是包名,即命名空间,学过java的应该都知道,这个参数是可选的
第三个Hello是程序(app)名字


3、后续操作都要在创建的项目目录下进行,执行:
cd hello


4、编译
运行build命令,输入不同平台标识,生成不同平台下的相应文件。
如下以android设备为例:
D:\hello> phonegap build android
D:\hello> cordova platform add android
D:\hello> cordova build android

要查看详细(verbose)执行过程,可增加命令参数-V :
D:\hello> phonegap -V build android
D:\hello> cordova platform add android
D:\hello> cordova -V build android
之后可以看到D:\hello\platforms\android里出现Android项目,这个项目可以用eclipse或android  studio打开。


5 、编译并运行(相当于上面build和install两步骤操作)
D:\hello> phonegap run android
D:\hello> cordova run android

也可用参数e专门指定运行在模块器上:
D:\hello> phonegap -e run android
D:\hello> cordova -e run android




附录:如果需要为webapp提供一些调用原生api或设备的功能,比如摄像头、电池信息、访问文件、读取通讯录等,需要为phongap项目添加phonegap插件。
添加插件的方法(确保已经安装了Git)
cmd执行下面的命令,即可添加对应功能的插件,下面是官方完整的插件列表,我直接拷贝过来,可能会有变化:


Basic device information 基本设备信息:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git

Network and battery status 网络和电池状态:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-battery-status.git

Accelerometer, compass, and geolocation 加速度计、指南针和地理位置:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

Camera, media capture, and media playback 摄像头、网页摄像头和多媒体播放:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-media.git

Access files on device or network 访问本地或网络文件:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-file.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer.git

Notifications via dialog box or vibration 提示框通知或震动:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-vibration.git

Contacts 通讯录:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-contacts.git

Globalization 全球化 多语言:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization.git

Splash Screen 启动画面:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-splashscreen.git

In-app browser App内嵌浏览器:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git

Debug console 调试控制台:
phonegap local plugin add http://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git    


下面是一些非官方的插件:




欢迎加入Sencha Touch + Phonegap交流群

1群:194182999 (满)

2群:419834979

共同学习交流(博主QQ:479858761


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

神秘_博士

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值