【发布时间】:2014-03-11 21:10:56
【问题描述】:
我正在尝试访问手机上的联系人。我正在使用下面的代码来执行此操作,但 navigator.contacts.find 不起作用。它不会返回错误或成功消息。如果我在该行代码之后放置任何类型的警报,它将不会出现。
function read_contacts(){
var options = new ContactFindOptions( );
options.filter = ""; //leaving this empty will find return all contacts
options.multiple = true; //return multiple results
var filter = ["displayName"]; //an array of fields to compare against the options.filter
navigator.contacts.find(filter, successFunc, errFunc, options); //breaking the code
function successFunc( matches ){
alert("reading contacts...");
for( var i=0; i<matches.length; i++){
alert( matches[i].displayName );
}
function errFunc(){
alert("Error finding contacts");
}
}
}
【问题讨论】:
标签: javascript android cordova android-contacts contact