如何将新的领域(S)添加到联系人? [英] How to add new field(s) to the contact?

查看:136
本文介绍了如何将新的领域(S)添加到联系人?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义字段添加到ContactsContract内容提供商。我试图建立一个VoIP应用,并想添加一个SIP地址(名称@域)字段它。我将需要与它相关联的什么MIME类型? 另外我想补充一组地址字段,这将有它的组地址(名@域名,名@域名,......)的列表。至极MIME类型将我必须用这种类型的字段关联。

I want to add a Custom field to the ContactsContract content provider. I'm trying to build a Voip application and would like to add a SIP address(name@domain) field to it. What MIME type will I need to associate with it? Also I want to add a group address field which will have a list of group addresses in it (name@domain, name@domain,...). Wich MIME type will I have to associate with this type of field.

我也想自定义字段添加到通话记录就像一个会话ID和SIP地址(名称@域)领域。我怎么可以自定义的通话记录?

I also want to add custom fields to the Call History like a session ID and SIP address(name@domain) field. How can I customize the call history?

这将是巨大的,如果有人可以给我一个例子。

It'll be great if someone can give me an example.

推荐答案

您必须创造自己的MIME类型的。

You have to creat your own mime type for those.

下面是保存一个布尔值,我的自定义MIME类型来接触一个例子。它采用最新的SDK 2.1

Here is an example that saves a boolean as my custom mime type to the contacts. It uses the latest SDK 2.1

public void saveFormality() {
        try {
            ContentValues values = new ContentValues();
            values.put(Data.DATA1, this.getFormality() ? "1" : "0");
            int mod = ctx.getContentResolver().update(
                    Data.CONTENT_URI,
                    values,
                    Data.CONTACT_ID + "=" + this.getId() + " AND "
                            + Data.MIMETYPE + "= '"
                            + clsContacts.FORMALITY_MIMETYPE + "'", null);

            if (mod == 0) {
                values.put(Data.CONTACT_ID, this.getId());
                values.put(Data.MIMETYPE, clsContacts.FORMALITY_MIMETYPE);
                ctx.getContentResolver().insert(Data.CONTENT_URI, values);
            }
        } catch (Exception e) {
            Log.v(TAG(), "saveFormality failed");
        }
    }

这篇关于如何将新的领域(S)添加到联系人?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆