I have a problem with cordova/phonegap contacts.
This is the code i am trying to execute, i put in an external javascript file:
function onDeviceReady() {
// find all contacts
var options = new ContactFindOptions();
options.filter = "*";
var fields = ["displayName", "name"];
navigator.contacts.find(fields, onSuccess, onError, options);
}
// onSuccess: Get a snapshot of the current contacts
function onSuccess(contacts) {
for (var i = 0; i < contacts.length; i++) {
console.log("Display Name = " + contacts[i].displayName);
}
}
// onError: Failed to get the contacts
function onError(contactError) {
alert('onError!');
}
This is the code from the phonegap API documentation:
link
The original code is to find all contacts with 'bob' in every field.
I changed it to "*"(Just a star) for all my contacts.
The function onDeviceReady is just called by a button click.
The error I get in the logcat is this:
[INFO:CONSOLE(81)] "Uncaught ReferenceError: ContactFindOptions is not defined"
81 is the linenumber with: var options = new ContactFindOptions();
Does anyone know what to do to get the function ContactFindOptions() work?
If you need more info, just let me know.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…