博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android 调用系统联系人界面的添加联系人,添加已有联系人,编辑和修改。
阅读量:7242 次
发布时间:2019-06-29

本文共 2171 字,大约阅读时间需要 7 分钟。

一、添加联系人

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);                                }

 

转载于:https://www.cnblogs.com/longhs/p/5435398.html

你可能感兴趣的文章
坦克大战---可能带BUG
查看>>
excel表数据分列
查看>>
3、kvm虚拟机日常管理与配置
查看>>
php各个模式、版本的区别
查看>>
shell中的点命令与source命令
查看>>
我的友情链接
查看>>
百度 ueditor 富文本编辑器的使用心得 jsp版本 1.4的JDK weblogic8
查看>>
软件安装
查看>>
增加点访问量
查看>>
MongoDB笔记十七——Mongodb导入
查看>>
sdfgsdf
查看>>
别人的tomcat配置
查看>>
linux基础命令练习题
查看>>
《Memcached应用实战》
查看>>
我的友情链接
查看>>
Linux 基础学习 文件查找命令 find 部分用法
查看>>
怎样成为一个高级的研发工程师
查看>>
Telnet部署与启动 windows&&linux
查看>>
落力在岁月青葱
查看>>
2015年春节往事小记
查看>>