Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改)
一、添加联系人
IntentaddIntent=newIntent(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(ContactsContract.Intents.Insert.NAME,number);
名称:addIntent.putExtra(android.provider.ContactsContract.Intents.Insert.PHONE,numberForNewConstant);
电话:
startActivity(addIntent);
二、添加到已有联系人
LogUtil.logI("================btnAddToOladContact=====================");
IntentoldConstantIntent=newIntent(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============");
三、编辑联系人
IntenteditIntent=newIntent(Intent.ACTION_EDIT,Uri.parse("content://com.android.contacts/contacts/"+cb.getContactId()));
startActivity(editIntent);
四、删除联系人
//*************删除联系人******************
UrideleteUri=ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI,cb.getContactId());
UrilookupUri=ContactsContract.Contacts.getLookupUri(ContactsDetailActivity.this.getContentResolver(),deleteUri);
if(lookupUri!=Uri.EMPTY){
intdel=ContactsDetailActivity.this.getContentResolver().delete(deleteUri,null,null);
LogUtil.logI("==========popupMenu============del:"+del);
}
以上所述是小编给大家介绍的Android调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!
热门推荐
10 读书祝福语女生短句简短
11 感谢同事新婚祝福语简短
12 感谢教官文案祝福语简短
13 员工聚会蛋糕祝福语简短
14 元宵发客户祝福语简短
15 给团队信心祝福语简短
16 医美的祝福语大全简短
17 异国姻缘的祝福语简短
18 兄妹拍照祝福语简短的话