Aamirkhan
Aamirkhan

Reputation: 5784

Phonegap Contact API Issue

i need to fetch contact list from android device using phonegap.....i have follow this one

PHONEGAP CONTACT API

and wrote this code

<!DOCTYPE html>

PhoneGap Device Ready Example

<script type="text/javascript" charset="utf-8" src="phonegap-1.4.1.js"></script>
<script type="text/javascript" charset="utf-8">

// Call onDeviceReady when PhoneGap is loaded.
//
// At this point, the document has loaded but phonegap-1.0.0.js has not.
// When PhoneGap is loaded and talking with the native device,
// it will call the event 'deviceready'.
// 
document.addEventListener("deviceready", onDeviceReady, false);

// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
    var options = new ContactFindOptions();
    options.filter="Bob"; 
    var fields = ["displayName", "name"];
    navigator.contacts.find(fields, onSuccess, onError, options);
}
 function onSuccess(contacts) {
    alert('OnSucess!');
    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!');
}

</script>

i have given this permission in my manifest

& this plugin

<plugin name="Contacts" value="com.phonegap.ContactManager"/>

i am using phonegap version 1.4.1,when i run my application always i get alert('OnError'); what should be the reason behind it? is it versioning problem?any guide is appreciated Thanks

Upvotes: 0

Views: 919

Answers (1)

RAJ PATEL
RAJ PATEL

Reputation: 594

Which ADT version you used?
If you use ADT 20 then you have to add phonegap jar manually in libs folder then it works.
Please try that and tell me.
And you can also refer my question which I ask and somewhat similar to you..

Phonegap application stops unexpectedly on Indigo running Android ADT 20

Upvotes: 2

Related Questions