Anthony Scuderi created CB-6429:
-----------------------------------
Summary: Stored numbers in a contacts array not be stored or
displayed properly
Key: CB-6429
URL: https://issues.apache.org/jira/browse/CB-6429
Project: Apache Cordova
Issue Type: Bug
Components: Android
Reporter: Anthony Scuderi
Priority: Minor
I was running this on Ubuntu 12.04 and with the 0331 build of RAD. This code
below was taken from the apache cordova website ==>
http://cordova.apache.org/docs/en/2.5.0/cordova_contacts_contacts.md.html .
I did modify the line one line to <script type="text/javascript"
charset="utf-8" src="cordova.js"></script>
Testing the contacts plugin on an android device. When I run this it should
print out the phone numbers that are stored in the contacts array. Seems like
that is not be stored properly. Not sure if this is a tools issue or more of a
cordova problem.
<!DOCTYPE html>
<html>
<head>
<title>Contact Example</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for Cordova to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// Cordova is ready
//
function onDeviceReady() {
// create a new contact
var contact = navigator.contacts.create();
// store contact phone numbers in ContactField[]
var phoneNumbers = [];
phoneNumbers[0] = new ContactField('work', '212-555-1234', false);
phoneNumbers[1] = new ContactField('mobile', '917-555-5432', true); //
preferred number
phoneNumbers[2] = new ContactField('home', '203-555-7890', false);
contact.phoneNumbers = phoneNumbers;
// save the contact
contact.save();
// search contacts, returning display name and phone numbers
var options = new ContactFindOptions();
options.filter="";
filter = ["displayName","phoneNumbers"];
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++) {
// display phone numbers
for (var j=0; j<contacts[i].phoneNumbers.length; j++) {
alert("Type: " + contacts[i].phoneNumbers[j].type + "\n" +
"Value: " + contacts[i].phoneNumbers[j].value + "\n" +
"Preferred: " + contacts[i].phoneNumbers[j].pref);
}
}
};
// onError: Failed to get the contacts
//
function onError(contactError) {
alert('onError!');
}
</script>
</head>
<body>
<h1>Example</h1>
<p>Find Contacts</p>
</body>
</html>
--
This message was sent by Atlassian JIRA
(v6.2#6252)