-1
Button btnEditAccount = (Button) popUpView.findViewById(R.id.contacts1);
btnEditAccount.setOnClickListener(new OnClickListener() 
{
    @Override
    public void onClick(View v) 
    {
        mpopup.dismiss();
        startActivityForResult(
            new Intent(
                Intent.ACTION_PICK,
                ContactsContract.CommonDataKinds.Email.CONTENT_URI
            ),
            REQUEST_CODE_PICK_CONTACTS
        );
    }
});

This is my code now i need to pick one email address from contacts which is having more emails in that contact

perissf
  • 15,979
  • 14
  • 80
  • 117
Bethan
  • 971
  • 8
  • 23
  • And what is the error ? – Prerak Sola Jul 20 '15 at 07:32
  • possible duplicate of [Get only email address from contact list Android](http://stackoverflow.com/questions/10117049/get-only-email-address-from-contact-list-android) – Soham Jul 20 '15 at 07:39
  • I need to pick the email address from the contacts manually but now i am able to pick all those emails present in a single contact – Bethan Jul 20 '15 at 07:49

1 Answers1

0

As you said you are already getting all the email in the single list. Now, you can retrieve the particular email address from the list by iterating the list based on the condition for the specific email id. For Example

ArrayList<String> listEmail;

for(int i=0; i<listEmail.length(); i++) {

 if(YOUR CONDITION TO GET SPECIFIC EMAIL ID WITH listEmail.get(i)) {
     //DO SOMETHING
  }
}
Vid
  • 1,012
  • 1
  • 14
  • 29
  • I think this will not suite for my code because exactly what i need is to pick one email address from the contact which is having more than one email. for ex: I have 4 contacts and each contact having three emails(home,work,other,....)so i need to pick exactly one e-mail address from that contact...so please let me know the solution – Bethan Jul 20 '15 at 09:25
  • I think the hierarchy is like this, suppose ContactsList contains list of two contacts xyz and abc. Now, xyz having three type of list homeEmail, workEmail and otherEmail and you want suppose workEmail of xyz. I am right?? – Vid Jul 20 '15 at 09:48
  • If really you want to do.. you have to use nested for loop to fetch the contacts from home ot work or others.. I have checked it and discussed with others also, there is no method to get direct. – Vid Jul 20 '15 at 10:08
  • Is there any option to go into the contact and select the mail address instead of directly clicking on the contacts and get email – Bethan Jul 20 '15 at 10:59