当我插入一个触点,它插入正常,但我得到一个"无名"条目在没有数据的顶端 [英] When I insert a contact, it inserts properly, but I get an "unnamed" entry at the top with no data

查看:276
本文介绍了当我插入一个触点,它插入正常,但我得到一个"无名"条目在没有数据的顶端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:我怀疑这是从我的HTC Sense UI中的错误导致。我也想接受一个答案让我来测试这个理论,而不会丢失任何电话数据(即硬重置或其他)。这款手机是HTC一个令人难以置信的Froyo运行2.2。

I suspect this is resulting from a bug in my HTC sense UI. I would also accept an answer allowing me to test this theory without losing any phone data (i.e. hard reset or otherwise). The phone is an HTC Incredible running Froyo 2.2.

我试图插入一个大批量的联系人(解析到通过XML对象,但基本上从自定义对象),我有上述问题。

I'm trying to insert a large batch of contacts (parsed into an object through XML, but basically from a custom Object) and I'm having the above problem.

联系人添加就好了(以com.google账户),但为每个联系人添加的,有一个接触无名添加到列表的顶部没有数据。

Contacts are adding just fine (to the "com.google" account), but for each contact added, there is a contact "unnamed" added to the top of the list with no data.

ctaList是我的接触加名单

ctaList is my "contact to add" list

tempFlr是我的对象持有的所有联系人,以原本补充。

tempFlr is my object holding all of the contacts to add originally.

code:

static ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

---------------------------------------------------------------------------
ArrayList<ContactToAdd> ctaList = new ArrayList<ContactToAdd>();
                constructCtaList(tempFlr, ctaList);

                ops.addAll(fillContentProviderOperation(accounts, ctaList,
                        ops));

---------------------------------------------------------------------------

private void constructCtaList(final FrontLineResponse tempFlr,
                ArrayList<ContactToAdd> ctaList) //
{
    for (Customer c : tempFlr.Customers) //
    {
        for (Applicant app : c.Applicants) //
        {
            ContactToAdd cta = constructContactToAdd(c, app);
            ctaList.add(cta);
        }
    }
}

---------------------------------------------------------------------------

protected ArrayList<ContentProviderOperation> addToContacts(
        ContactToAdd cta, int opsLength, Account[] accounts) //
{

    // opsLength is used to store the index to point at the RawContact
    // created here
    ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();

    ops.add(ContentProviderOperation.newInsert(RawContacts.CONTENT_URI)
            .withValue(RawContacts.ACCOUNT_TYPE, accounts[0].type)
            .withValue(RawContacts.ACCOUNT_NAME, accounts[0].name).build());

    ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
            .withValueBackReference(Data.RAW_CONTACT_ID, opsLength)
            .withValue(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE)
            .withValue(StructuredName.GIVEN_NAME, cta.FirstName)
            .withValue(StructuredName.FAMILY_NAME, cta.LastName).build());

    ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
            .withValueBackReference(Data.RAW_CONTACT_ID, opsLength)
            .withValue(Data.MIMETYPE, Phone.CONTENT_ITEM_TYPE)
            .withValue(Phone.NUMBER, cta.DayWorkPhoneNumber.PhoneNumber)
            .withValue(Phone.TYPE, Phone.TYPE_MOBILE).build());

    ops.add(ContentProviderOperation.newInsert(Data.CONTENT_URI)
            .withValueBackReference(Data.RAW_CONTACT_ID, opsLength)
            .withValue(Data.MIMETYPE, Email.CONTENT_ITEM_TYPE)
            .withValue(Email.DATA1, cta.Email)
            .withValue(Email.TYPE, Email.TYPE_MOBILE).build());

    ops.add(ContentProviderOperation
            .newInsert(Data.CONTENT_URI)
            .withValueBackReference(Data.RAW_CONTACT_ID, opsLength)
            .withValue(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE)
            .withValue(StructuredPostal.STREET, cta.MailingAddress.Address1)
            .withValue(StructuredPostal.CITY, cta.MailingAddress.City)
            .withValue(StructuredPostal.REGION,
                    cta.MailingAddress.StateCode)
            .withValue(StructuredPostal.POSTCODE,
                    cta.MailingAddress.PostalCode)
            .withValue(StructuredPostal.TYPE, StructuredPostal.TYPE_HOME)
            .build());

    ops.add(ContentProviderOperation
            .newInsert(Data.CONTENT_URI)
            .withValueBackReference(Data.RAW_CONTACT_ID, opsLength)
            .withValue(Data.MIMETYPE, StructuredPostal.CONTENT_ITEM_TYPE)
            .withValue(StructuredPostal.STREET,
                    cta.ShippingAddress.Address1)
            .withValue(StructuredPostal.CITY, cta.ShippingAddress.City)
            .withValue(StructuredPostal.REGION,
                    cta.ShippingAddress.StateCode)
            .withValue(StructuredPostal.POSTCODE,
                    cta.ShippingAddress.PostalCode)
            .withValue(StructuredPostal.TYPE, StructuredPostal.TYPE_WORK)
            .build());

    return ops;
}

谢谢!

推荐答案

它看起来像这样是的Sense UI宏达特产。这是通过简单的清洗数据之前,我插入ContentProvider的解决。

It looks like this is a peculiarity of the Sense UI for HTC. This was solved by simply cleansing the data before I inserted it into the ContentProvider.

希望这有助于任何人通过这种困惑!

Hope this helps anybody confused by this!

这篇关于当我插入一个触点,它插入正常,但我得到一个&QUOT;无名&QUOT;条目在没有数据的顶端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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