title: Access contacts on Android using Phonegap
body: <p>I'm working on an application using phone-gap. 
  I'm trying to access the contacts on the mobile coz I'll use them later. 
  I'm now trying to write a code to find contacts on the mobile. 
  Here's the JS file I'm using:</p>
  
  <pre><code>alert('Starting JS');
  var TAP = ('ontouchend' in window) ? 'touchend' : 'click';
  alert('I entered the function'); 
  
     document.addEventListener('DOMContentLoaded', function () {
     alert('I entered the second function');
  
         x$('#friendSubmit').on(TAP, function () {
             var filter = x$('#friendName')[0].value;
             alert('I entered the third function');
  
             if (!filter)
              {
              alert('Cant find contacts');
  
                  // no contents
                  return;
              } 
             else 
             {
                findContactByName(filter, function (contacts) 
                {
  
     alert(contacts.length + ' contact(s) found matching "' +filter + '"');
    }
  ); }               
  
    }); });
    function findContactByName(name, callback) {
         function onError() {
             alert('Error: unable to read contacts');
         };
         var fields = ["displayName", "name"],
             options = new ContactFindOptions();
         options.filter = name;
         options.multiple = true;
         // find contacts
         navigator.service.contacts.find(fields, callback, onError,
         options);
       ￼}
  </code></pre>
  
  <p>None of the alerts are alerted, so it seems that something is wrong in the code (but it alerted when I removed the "findContactByName" function. </p>
  
  <p>Do you know If I should add any kind of plugins, or update anything so that these functions can work ? 
  I'm working with cordova version 1.6.1 and I updated the permissions at the manifest to be able to access the contacts. 
  So, do you know what's wrong with my code &amp; why isn't it working? </p>
  
  <p>Thanks a lot. </p>