使用Intent.ACTION_EDIT 调用系统编辑联系人
2015-11-06 11:40
357 查看
参看官方文档:http://developer.android.com/guide/topics/providers/contacts-provider.html#Access 的Retrieval
and modification with intents 部分:
本文讨论的是编辑指定的联系人,否则你应该使用Intent.ACTION_INSERT_OR_EDIT
涉及到的Action是:Intent.ACTION_EIDT
涉及到的Provider契约类常量是:
Contacts.CONTENT_LOOKUP_URI 指定相关联系人的URI
Contacts.CONTENT_ITEM_TYPE 指定联系人的MIME类型
重点是如何构建一个指定联系人的Contacts.CONTENT_LOOKUP_URI
官网对Contacts.CONTENT_LOOKUP_URI的说明是:
A content:// style URI for this table that should be used to create shortcuts or otherwise create long-term links to contacts. This URI should always be followed by a "/" and the contact's LOOKUP_KEY.
It can optionally also have a "/" and last known contact ID appended after that. This "complete" format is an important optimization and is highly recommended.
As long as the contact's row ID remains the same, this URI is equivalent to CONTENT_URI.
If the contact's row ID changes as a result of a sync or aggregation, this URI will look up the contact using indirect information (sync IDs or constituent raw contacts).
Lookup key should be appended unencoded - it is stored in the encoded form, ready for use in a URI.
以上大致意思是,可以通过如下两种方式构建:
第一种:
?
第二种:
?
首先是如何获得联系人的LOOKUP_KEY和ID,通常情况下,当你使用Intent.ACTION_EDIT方式时,说明你已经拿到了一个CONTENT_LOOKUP_URI,为了对以上代码更好的说明和方便起见我们通过如下代码块打开联系人应用,从中挑选一个联系人加以说明:
?
通过以上步骤就拿到了content_lookup_uri,通过下面代码块来对指定联系人进行编辑
?
当然多数时候我们直接使用Intent.ACTION_INSERT_OR_EDIT来编辑联系人 本文只是讨论在使用Intent.ACTION_EDIT时的注意事项
and modification with intents 部分:
本文讨论的是编辑指定的联系人,否则你应该使用Intent.ACTION_INSERT_OR_EDIT
涉及到的Action是:Intent.ACTION_EIDT
涉及到的Provider契约类常量是:
Contacts.CONTENT_LOOKUP_URI 指定相关联系人的URI
Contacts.CONTENT_ITEM_TYPE 指定联系人的MIME类型
重点是如何构建一个指定联系人的Contacts.CONTENT_LOOKUP_URI
官网对Contacts.CONTENT_LOOKUP_URI的说明是:
A content:// style URI for this table that should be used to create shortcuts or otherwise create long-term links to contacts. This URI should always be followed by a "/" and the contact's LOOKUP_KEY.
It can optionally also have a "/" and last known contact ID appended after that. This "complete" format is an important optimization and is highly recommended.
As long as the contact's row ID remains the same, this URI is equivalent to CONTENT_URI.
If the contact's row ID changes as a result of a sync or aggregation, this URI will look up the contact using indirect information (sync IDs or constituent raw contacts).
Lookup key should be appended unencoded - it is stored in the encoded form, ready for use in a URI.
以上大致意思是,可以通过如下两种方式构建:
第一种:
?
?
?
?
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories