Why always the first number is dialled..!
<p>I am writing code for searching a contact and making the call. My code can list the contact names and select particular contact. But when i dial to that selected contact, it speaks out the selected name but dials to the first name in the contact list.Can anyone help me how to write the code for calling particular number by selecting the name from the list of contacts.
Thanks in advance.</p>

<p>here is the code that i use to search particular contact number. but selects the first number.                          </p>

<pre><code> private void populateContacts()
 { 

   ContentResolver cr = getContentResolver(); 

   Cursor cur = cr.query(ContactsContract.Contacts.CONTENT_URI, null,  null, null, null); 

   if (cur.getCount() &gt; 0) { 

   while (cur.moveToNext())
   { 

       // ID AND NAME FROM CONTACTS CONTRACTS 
        id = cur.getString(cur.getColumnIndex(ContactsContract.Contacts._ID)); 

        // GET PHONE NUMBERS WITH QUERY STRING 
      if (Integer.parseInt(cur .getString(cur.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) &gt; 0) { 

        Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI,null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID 
                       + " = ?", new String[] { id }, null); 

         // WHILE WE HAVE CURSOR GET THE PHONE NUMERS 
        while (pCur.moveToNext())
         { 

              name = cur .getString(cur .getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));    

             Log.i("jni", "ID :" + id); 
             Log.i("jni", "NAME :" + name); 

                 // Do something with phones 
                 //int phoneColumn = pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA);
                 //      number =pCur.getString(phoneColumn);

            phone = pCur.getString(pCur .getColumnIndex(ContactsContract.CommonDataKinds.Phone.DATA)); 

           Contacts.add( name+ phone  );
         }

  } 
    //      pCur.close(); 

 } 
</code></pre>
