Question

I need to select emails from contact... I find android have a build-in phone number picker as seen on image bellow.

img : http://i1108.photobucket.com/albums/h412/Tek_Yin/selectphone.jpg

in 1.5 & 1.6 I can use this :

Intent i = new Intent(Intent.ACTION_PICK, Contacts.Phones.CONTENT_URI);

the question is :

  • can it show email instead of phone number?
  • I need it to adapt on 2.0 or higher
  • I read 2.0 or higher is using ContactsContract, but how?

Thanks in advance.

Was it helpful?

Solution

just override @Override onActivityResult and create a cursor for email, when you get the results for picker, get only the email addreess.

email = Emailcursor.getString(Emailcursor.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));

OTHER TIPS

You can launch a contact picker that only displays email addresses using ContactsContract like this

Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Email.CONTENT_URI);  
startActivityForResult(intent, 1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top