hi...
u can call the intent whenever u want to retrive number from phone
booki m attaching sample code which i have implemented and it works
for me for version above 1.6
........................................................................................................................................
addcontact =(Button) findViewById(R.id.addphonenofromcontact);
        addcontact.setOnClickListener(new View.OnClickListener()
        {public void onClick(View V)
                {Intent ContactPickerIntent = new
Intent(Intent.ACTION_PICK,ContactsContract.Contacts.CONTENT_URI);
                startActivityForResult(ContactPickerIntent,
CONTACT_PICKER_RESULT);
                } });
...........................................................................................................................................
Now as i have called startactivity for result i have to wait for the
result to come from there. Its implementation is here.
..........................................................................................................................................

 protected void onActivityResult(int requestCode, int resultCode,
Intent data) {
             if (resultCode == RESULT_OK)
             {
                 switch (requestCode)
                 {
                 case CONTACT_PICKER_RESULT:
                         Cursor cursor=null;
                         try
                         {
                                 Uri result = data.getData();
                                 Log.v(DEBUG_TAG, "Got a contact result: " +
result.toString());

                                 // get the contact id from the Uri
                                 String id = result.getLastPathSegment();

                                 // query for everything contact number
                                 cursor = getContentResolver().query(
                                  Phone.CONTENT_URI, null,
                                  Phone.CONTACT_ID + "=?",
                                  new String[]{id}, null);

                                 cursor.moveToFirst();
                                 int phoneIdx = 
cursor.getColumnIndex(Phone.DATA);
                                 if (cursor.moveToFirst())
                                 {
                                         phonenofromcontact = 
cursor.getString(phoneIdx);
                                         finallistofnumberstosendmsg 
+=","+phonenofromcontact;
                                         Log.v(DEBUG_TAG, "Got phone no : " +
phonenofromcontact);
                                 }
                                 else
                                 {
                                         Log.w(DEBUG_TAG, "No results");
                                 }
                         }
                         catch(Exception e)
                         {
                                 Log.e(DEBUG_TAG, "Failed to get contact 
number", e);
                         }
                         finally
                         {
                                 if (cursor != null)
                                 {
                                         cursor.close();
                                 }
                         }
                         phonePhoneno=
(EditText)findViewById(R.id.Phonenofromcontact);
                         phonePhoneno.setText(finallistofnumberstosendmsg);
                         //phonePhoneno.setText(phonenofromcontact);
                         if(phonenofromcontact.length()==0)
                         {
                                 Toast.makeText(this, "No contact number found 
for this
contact",
                                                 Toast.LENGTH_LONG).show();
                         }
                    break;
                 }
             }
             else
             {
                 Log.w(DEBUG_TAG, "Warning: activity result not ok");
             }
         }
...............................................................................................................................................................
if u want to use it for the version before 1.6 then use people
class...


Is that answer your question??

Thanks..
Rakesh

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to