开发者

Program adding contacts on the emulator does not add contacts on the HTC Desire

I want to write a program to automatically generate the contacts. I also use a special service to add account on emulator. The same account is used on the telephone. Below is my code:

ContentValues values = new ContentValues();
values.put(RawContacts.ACCOUNT_TYPE, "localhost");
values.put(RawContacts.ACCOUNT_NAME, "PC Sync");
Uri rawContactUri = getContentResolver().insert(RawContacts.CONTENT_URI, values);
long rawContactId = ContentUris.parseId(rawContactUri);             

values.clear();
values.put(Data.RAW_CONTACT_ID, rawContactId);
values.put(Data.MIMETYPE, StructuredName.CONTENT_ITEM_TYPE);
values.put(StructuredName.GIVEN_开发者_StackOverflow社区NAME, Gname);
values.put(StructuredName.FAMILY_NAME, Fname);
values.put(StructuredName.MIDDLE_NAME, Mname);
getContentResolver().insert(Data.CONTENT_URI, values);

The program is working on emulator and adds contacts, but on HTC the program only process adding no contacts. I can't understand what the problem can be.


I think that's the solution Android: Enable imported account contacts programmatically. You should specify UNGROUPED_VISIBLE=1 to make new contacts visible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜