<2> 我们从命令行进入 到工程目录下的 plugins文件夹
cd my-app
cd plugins
<3> 现在开始下载插件
cordova plugin add org.apache.cordova.contacts
<4> 添加android 平台工程 (ios把 “android” 替换)
cordova platform add android
<5> 编译android工程
cordova build
至此 contacts 插件已经生成并添加到项目当中去…
现在项目应该 有如下文件:
cordova-plugins.js 里面的文件是:
cordova.define(‘cordova/plugin_list’, function(require, exports, module) {
module.exports = [
{
“file”: “plugins/org.apache.cordova.contacts/www/contacts.js”,
“id”: “org.apache.cordova.contacts.contacts”,
“clobbers”: [
“navigator.contacts”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/Contact.js”,
“id”: “org.apache.cordova.contacts.Contact”,
“clobbers”: [
“Contact”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/ContactAddress.js”,
“id”: “org.apache.cordova.contacts.ContactAddress”,
“clobbers”: [
“ContactAddress”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/ContactError.js”,
“id”: “org.apache.cordova.contacts.ContactError”,
“clobbers”: [
“ContactError”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/ContactField.js”,
“id”: “org.apache.cordova.contacts.ContactField”,
“clobbers”: [
“ContactField”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/ContactFindOptions.js”,
“id”: “org.apache.cordova.contacts.ContactFindOptions”,
“clobbers”: [
“ContactFindOptions”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/ContactName.js”,
“id”: “org.apache.cordova.contacts.ContactName”,
“clobbers”: [
“ContactName”
]
},
{
“file”: “plugins/org.apache.cordova.contacts/www/ContactOrganization.js”,
“id”: “org.apache.cordova.contacts.ContactOrganization”,
“clobbers”: [
“ContactOrganization”
]
}
];
module.exports.metadata =
// TOP OF METADATA
{
“org.apache.cordova.contacts”: “0.2.8”
}
// BOTTOM OF METADATA
});
res/xml 目录下 的config.xml
在config.xml 里面有
现在大家只需要将工程导入到eclipse当中 使用官方APi语句在javascript中调用
将下方语句考到 assets目录下 www/index.html 当中 完全复制过去;
example: