如何一次选择多个联系人?

| 我使用以下代码将电话簿联系人检索到我的应用程序:
public void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Intent contactPickerIntent = new Intent(Intent.ACTION_PICK,  
                                            Contacts.CONTENT_URI);  
    startActivityForResult(contactPickerIntent, CONTACT_PICKER_RESULT);      
}
但是我想选择多个联系人并将其上传到数据库。这可能吗,如果可以,我该怎么做?     
已邀请:
好了,您可以直接在活动内部查询内容提供者,以便用户可以选择多个联系人。这可以使用联系人合同来实现。有关更多信息,请查看api文档或本教程博客文章。     
试试这个代码..
     people = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
    int position=0;
    Cursor q=db.query(mProfile,new String[]{\"person_name\"},\"person_name\"+\"!=\'\"+null+\"\'\",null,null, null, null);
    people.moveToFirst();
        int nameFieldColumnIndex = people.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);    
        while(!people.isAfterLast()) {
            Cursor o=db.query(mProfile,new String[]{\"person_name\"},\"person_name\"+\"=\'\"+people.getString(nameFieldColumnIndex)+\"\'\",null,null, null, null);
            if(!(o.getCount()>0))
            {  
            mConname.add(position, people.getString(nameFieldColumnIndex));
            try{
                String contactId = people.getString(people.getColumnIndex(ContactsContract.Contacts._ID));
                String hasPhone = people.getString(people.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER));
                if ( hasPhone.equalsIgnoreCase(\"1\"))
                    hasPhone = \"true\";
                else
                    hasPhone = \"false\" ;
                if (Boolean.parseBoolean(hasPhone)) 
                {
                    Cursor phones = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null,ContactsContract.CommonDataKinds.Phone.CONTACT_ID +\" = \"+ contactId,null, null);
                    while (phones.moveToNext()) 
                    {
                        String phoneNumber = phones.getString(phones.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
                        mConno.add(position,phoneNumber);

                    }
                    phones.close(); 
                }   
                if(hasPhone==\"false\")
                {   mConname.remove(position);
                }   
                else
                    position++;
            }       
            catch(Exception e)
            { 

            }
        }
            people.moveToNext();
        }
使用sqlite并存储     

要回复问题请先登录注册