EDIT:これはHTCのセンスUIのバグの原因と思われます。また、電話機のデータを失うことなくこの理論をテストできるようにする回答も受け入れます(ハードリセットなど)。電話は、HTC IncredibleのFroyo 2.2を実行しています。連絡先を挿入すると正しく挿入されますが、上部にはデータなしの「名前のない」エントリが表示されます
大きなバッチの連絡先(XMLを使ってオブジェクトに解析されましたが、基本的にはカスタムオブジェクトから)を挿入しようとしていますが、上記の問題があります。
連絡先は「com.google」アカウントに追加されていますが、追加された連絡先ごとに、「名前なし」という連絡先がデータのないリストの先頭に追加されています。
ctaListはリスト
tempFlrは、もともと追加する連絡先のすべてを保持し、私のオブジェクトであるが、私の「追加するための接触」です。
コード:
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;
}
ありがとう!