Phonegap联系人插件在Android上对我不起作用。我正在使用phonegap构建
联系人插件在Android上不适用于我。我正在使用phonegap构建 我在config.xml中添加了这个Phonegap联系人插件在Android上对我不起作用。我正在使用phonegap构建,android,cordova,phonegap-plugins,phonegap-build,Android,Cordova,Phonegap Plugins,Phonegap Build,联系人插件在Android上不适用于我。我正在使用phonegap构建 我在config.xml中添加了这个 <gap:plugin name="org.apache.cordova.contacts" /> 这是我的密码: document.addEventListener("deviceready", onDeviceReady, false); // PhoneGap is ready function onDeviceReady() { // specify
<gap:plugin name="org.apache.cordova.contacts" />
这是我的密码:
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is ready
function onDeviceReady() {
// specify contact search criteria
var options = new ContactFindOptions();
options.filter=""; // empty search string returns all contacts
options.multiple=true; // return multiple results
filter = ["displayName"]; // return contact.displayName field
navigator.contacts.find(filter, onSuccess, onError, options);
}
// onSuccess: Get a snapshot of the current contacts
function onSuccess(contacts) {
for (var i=0; i<contacts.length; i++) {
alert(contacts[i].displayName);
}
};
// onError: Failed to get the contacts
function onError(contactError) {
alert('onError!');
}
document.addEventListener(“DeviceRady”,OnDevicerady,false);
//PhoneGap已经准备好了
函数ondevicerady(){
//指定联系人搜索条件
var options=new ContactFindOptions();
options.filter=”“;//空搜索字符串返回所有联系人
options.multiple=true;//返回多个结果
筛选器=[“displayName”];//返回contact.displayName字段
navigator.contacts.find(过滤器、onSuccess、onError、选项);
}
//onSuccess:获取当前联系人的快照
成功时的功能(联系人){
对于(var i=0;i请尝试向回调添加作用域:onSuccess
和onError
在联系人函数调用中。使用应用程序的主作用域app
或您设置的任何内容
navigator.contacts.find(filter, app.onSuccess, app.onError, options);
您是否遇到任何特殊错误?警报('onError')是否
fire?我没有收到任何错误。实际上,成功函数和错误函数都没有执行。deviceready是否正在启动?尝试在onDeviceReady函数中添加警报是的deviceready正在启动。它起作用了。我更改了传递参数的顺序。navigator.contacts.find(onSuccess,onError,filter,options);