Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改)
更新时间:2017年03月07日 15:56:09 作者:三世铜棺
这篇文章主要介绍了Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改),非常不错,具有参考借鉴价值,需要的朋友可以参考下
一、添加联系人
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(ContactsContract.Intents.Insert.NAME,number);
名称: 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);
}
以上所述是小编给大家介绍的Android 调用系统联系人界面(添加联系人,添加已有联系人,编辑和修改),希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
相关文章
Android Studio出现Failed to pull selection: open failed: Permi
本篇文章给大家分享了Android Studio中导出数据库文件的方法以及出现Failed to pull selection: open failed: Permission denied的解决思路,有兴趣的学习下。2018-05-05
Android编程使用自定义shape实现shadow阴影效果的方法
这篇文章主要介绍了Android编程使用自定义shape实现shadow阴影效果的方法,涉及Android中xml文件布局的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下2015-11-11
Android Studio 3.3.2 正式版的安装教程图解
这篇文章主要介绍了Android Studio 3.3.2 正式版的安装教程图解,本文分步骤通过图文并茂的形式给大家介绍的非常详细,需要的朋友可以参考下2020-02-02


最新评论