插入接触机器人与ContactsContract [英] Insert contact in Android with ContactsContract

查看:152
本文介绍了插入接触机器人与ContactsContract的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为添加新的联系人到Android 2.2直接接触。

I am trying to add a new contact to the Android 2.2 contacts directly.

//this code doesn't work    
ContentValues cv=new ContentValues();
cv.put(ContactsContract.Contacts.DISPLAY_NAME, "TESTEST");
Uri u= getContentResolver().insert(ContactsContract.Contacts.CONTENT_URI, cv);

给我的错误集合联系人被自动创建。 我究竟做错了什么?

gives me the error "Aggregate contacts are created automatically." What am I doing wrong?

这调用了Android的添加联系人的形式

This calls the Android's add contact form:

//this code works but it's not ideal
Intent i = new Intent(Intent.ACTION_INSERT_OR_EDIT);
i.setType(Contacts.CONTENT_ITEM_TYPE);
i.putExtra(Insert.NAME, "TESTTEST");
i.putExtra(Insert.PHONE, "209384");
startActivity(i);

我不知道如何向它发送一个名字和姓氏 - 只有一个名称,它使在第一个名称框中。此外,我想分开邮政code到街道,城市,州和邮编这现在是所有被放进街道框。

I can't figure out how to send it a first name and a last name - only a 'name' which it puts in the first name box. Also I'd like to separate the postal code into street, city, state, and zip which right now is all being put into the street box.

推荐答案

问题解决了。发现这个quesiton;工作答案是阿尔斯:插入联系人的Andr​​oid 2.2

Problem solved. Found this quesiton; the working answer is by Als: Inserting contacts in Android 2.2

这篇关于插入接触机器人与ContactsContract的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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