Wednesday, November 11, 2009

[android-developers] Get list of pnones for certain person using new ContactsContract API

Hi, friends!

I spent much time to implement my old source code (for Android 1.6)
using new ContactsContract API (Android 2.0). But I couldn't.

My application shows user dialog with list of all people presented in
"Contacts". For this goal i use such code:

Intent intentListPeople = new Intent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
MyActivity.this.startActivityForResult(intentListPeople,
PICK_CONTACT);

After that for person, user picked in dialog, i need to get all phones
and i use them in my application.

For old android API (1.6) i used such source code:
(uriPerson - is the uri of a person, user picked in the first dailog)

ArrayList<String> listPhones = new ArrayList<String>();

Uri uriPhones = Uri.withAppendedPath(uriPerson,
Contacts.People.Phones.CONTENT_DIRECTORY);
Cursor curToPhones = this.managedQuery(uriPhones, null, null,
null, null);

if(curToPhones.moveToFirst())
{
int idPhoneNumberColumn =
curToPhones.getColumnIndexOrThrow
(Contacts.PhonesColumns.NUMBER);
while(!curToPhones.isAfterLast())
{
listPhones.add(curToPhones.getString
(idPhoneNumberColumn));
curToPhones.moveToNext();
}
}

Please, help to implement such functionality using new
ContactsContract API.
Thank you!

--
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate