那夜我还很年幼~
我不去想身后会不会袭来寒风冷雨 既然目标是地平线 留给世界的只能是背影

一、添加联系人

Intent addIntent = new Intent(Intent.ACTION_INSERT,Uri.withAppendedPath(Uri.parse("content://com.android.contacts"), "contacts"));
            addIntent.setType("vnd.android.cursor.dir/person");
            addIntent.setType("vnd.android.cursor.dir/contact");
            addIntent.setType("vnd.android.cursor.dir/raw_contact");
            addIntent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE, numberForNewConstant);
            startActivity(addIntent);

二、添加到已有联系人

LogUtil.logI("================btnAddToOladContact=====================");
            Intent oldConstantIntent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
            oldConstantIntent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
            oldConstantIntent.putExtra(ContactsContract.Intents.Insert.PHONE, numberForNewConstant);
            oldConstantIntent.putExtra(ContactsContract.Intents.Insert.PHONE_TYPE, 3);
            startActivity(oldConstantIntent);
            if(oldConstantIntent.resolveActivity(getActivity().getPackageManager()) != null){
                LogUtil.logI("================btnAddToOladContact=========yes============");
                startActivity(oldConstantIntent);
            }else
                LogUtil.logI("================btnAddToOladContact=========no============");

 

三、编辑联系人

Intent editIntent = new Intent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+cb.getContactId()));
                        startActivity(editIntent);

 

四、删除联系人

//*************删除联系人******************
                                Uri deleteUri = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, cb.getContactId());
                                Uri lookupUri = ContactsContract.Contacts.getLookupUri(ContactsDetailActivity.this.getContentResolver(), deleteUri);
                                if (lookupUri != Uri.EMPTY) {
                                    int del = ContactsDetailActivity.this.getContentResolver().delete(deleteUri, null, null);
                                    LogUtil.logI("==========popupMenu============del:"+del);


                                }

 

posted on 2016-04-26 15:52  那夜我还很年幼~  阅读(4633)  评论(0编辑  收藏  举报