0

So i'm trying to create a button in android studio that will open a contacts selection box that looks like the contacts selection when sending S.M.S (allow to choose more than one contact, letting you choose groups of contacts).

  1. i have tried this code, but it only letting you choose one contact:

    private static final int CONTACT_PICKER_RESULT = 1001;
    
    public void doLaunchContactPicker(View view) {
    Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
    startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);
    }
    
  2. after the user will select the contacts, how will i get the info?

update:

as @Allu i didn't find a way that i wont have to design this all by myself. eventually i wrote this code to get the groups and used ListView to display them to the users:

public class myGroup {
private String _ID;
private String _TITLE;
private ArrayList<String> _PHONE_NUMBERS;

     public  myGroup(String id, String title){
        _ID = id;
        _TITLE = title;
        //get the contacts phone numbers
        //_PHONE_NUMBERS.add();
     }
}

private ArrayList<myGroup> getGroups(){
    ArrayList<myGroup> myGroups = new ArrayList<myGroup>();
    Cursor cursor =getContentResolver().query(ContactsContract.Groups.CONTENT_URI,new String[]{ContactsContract.Groups._ID, ContactsContract.Groups.TITLE}, null, null, null);
    cursor.moveToFirst();
    int len = cursor.getCount();
    String[] a = cursor.getColumnNames();
    for(int i = 0; i < len; i++){
        if(cursor.getColumnIndex(ContactsContract.Groups.DELETED) == 1){
            continue;
        }
        myGroups.add(new myGroup(cursor.getString(cursor.getColumnIndex(Groups._ID)),
                cursor.getString(cursor.getColumnIndex(ContactsContract.Groups.TITLE))));
        cursor.moveToNext();
    }
    return myGroups;
}
jww
  • 97,681
  • 90
  • 411
  • 885
etamar211
  • 53
  • 7
  • please check this links it may helpful http://stackoverflow.com/questions/10449416/android-multiple-contacts-chooser-with-option-of-choosing-which-phone-number ,,,, http://stackoverflow.com/questions/15620805/how-to-select-multiple-contacts-from-the-phone-using-checkboxes – Hanuman Apr 06 '15 at 14:14
  • @Allu and what with the groups view? – etamar211 Apr 06 '15 at 14:20
  • i didn't get you, means you want to send sms for one group which is added with some contacts – Hanuman Apr 06 '15 at 14:25
  • @Allu can i show the user the lists of the groups?, then he will choose what groups he wants to send SMS to? – etamar211 Apr 06 '15 at 14:35
  • i don't know much about just see this link http://stackoverflow.com/questions/4334649/accessing-android-contact-group-names otherwise programmatically you can create group with some contacts and show that groups when he clicks on select groups search in net you can find good solutions. – Hanuman Apr 06 '15 at 14:42

0 Answers0