add contact to a group in Android

前端 未结 4 929
南旧
南旧 2021-01-16 22:15

I am working on android apps. I want to add a contact in android phone group. The code I am using is below:

    ContentValues values = new ContentValues();
          


        
4条回答
  •  失恋的感觉
    2021-01-16 22:45

        Intent intent = new Intent(Intent.ACTION_INSERT);
                    intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
    
                    intent.putExtra(ContactsContract.Intents.Insert.NAME, fullname);
    intent.putExtra(ContactsContract.Intents.Insert.PHONE,phoneno);
                    intent.putExtra(ContactsContract.Intents.Insert.EMAIL, email);
                    intent.putExtra(ContactsContract.Intents.Insert.NOTES,
                            "Imported from moodle");
                    intent.putExtra(ContactsContract.Intents.Insert.POSTAL, city
                            + " " + country);
    
                    startActivityForResult(intent, 1);
    
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
            if (resultCode == RESULT_OK) {
                switch (requestCode) {
                case 1:
                    if (requestCode == 1) {
    
                    }
                    super.onActivityResult(requestCode, resultCode, data);
                }
            }
        }
    

提交回复
热议问题