我已经按照电话差距网站上的文档编写了代码
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// find all contacts
var options = new ContactFindOptions();
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);
var element = document.getElementById('cont');
element.innerHTML='<li><a href="#">' + contacts[i].displayName + '</a></li>';
}
}
// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}
</script>`
它在安卓模拟器中运行良好,但是当我安装应用程序三星银河手机时,它返回一个“null”。请帮助。