Android 以编程方式添加的新联系人在“联系人”应用程序中不可见

Android 以编程方式添加的新联系人在“联系人”应用程序中不可见,android,Android,我正在用Android 1.6开发一个应用程序(不能使用2.0或更早版本) 我在手机上添加新联系人,如下所示: ContentValues contentValues = new ContentValues(); contentValues.put(Contacts.People.NAME, name); Uri contactUri = this.getContentResolver().insert(Contacts.People.CONTENT_URI, contentValues);

我正在用Android 1.6开发一个应用程序(不能使用2.0或更早版本)

我在手机上添加新联系人,如下所示:

ContentValues contentValues = new ContentValues();
contentValues.put(Contacts.People.NAME, name);

Uri contactUri = this.getContentResolver().insert(Contacts.People.CONTENT_URI, contentValues);
之后,我用同样的方法添加电话号码。它的工作原理是,我可以通过以下代码查看新添加的联系人:

Intent intent = new Intent(Intent.ACTION_VIEW, contactUri);
this.startActivity(intent);
我的问题是,在添加和查看新联系人后,我无法在联系人应用程序中看到它,除非我同步了所有联系人(我还搜索了联系人的姓名,找到了它,但它没有添加到联系人列表中)

如何以编程方式更新联系人,以便立即在“联系人”应用程序中添加新联系人


谢谢大家!

我找到了答案:添加新联系人(插入)后,使用
Contacts.People.addToMyContactsGroup()方法将其添加到myContactsGroup中:

// get new contact id :

int contactId = Integer.valueOf(contactUri.toString().substring(contactUri.toString().lastIndexOf("/")+1));

// add the new contact to myContactsGroup to have it in Contacts Application :

Contacts.People.addToMyContactsGroup(this.getContentResolver(), contactId);

我找到了答案:在添加新联系人(insert)后,使用
Contacts.People.addToMyContactsGroup()方法将其添加到myContactsGroup:

// get new contact id :

int contactId = Integer.valueOf(contactUri.toString().substring(contactUri.toString().lastIndexOf("/")+1));

// add the new contact to myContactsGroup to have it in Contacts Application :

Contacts.People.addToMyContactsGroup(this.getContentResolver(), contactId);

[Contacts.People]此类型已弃用,是否有新建议?[Contacts.People]此类型已弃用,是否有新建议?