插入联系意图、多个电话/电子邮件/等类型?
android 允许我发起创建新联系人的意图。我可以在意图中添加额外内容以预先填写新的联系字段。
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.NAME, "Foo Bar");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "(408) 555-1212");
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, "[email protected]");
startActivityForResult(intent, INSERT_CONTACT_REQUEST);
这可行,但我不知道如何处理给定字段的多种类型,例如电话号码。在意图中,我可以添加额外的电话号码,并且我可以添加额外的电话号码类型,但是如何添加额外的附加电话号码,具有不同的(甚至可能相同)类型?
android allows me to launch an intent to create a new contact. i can put extras into the intent to pre-fill the new contact fields.
Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);
intent.putExtra(ContactsContract.Intents.Insert.NAME, "Foo Bar");
intent.putExtra(ContactsContract.Intents.Insert.PHONE, "(408) 555-1212");
intent.putExtra(ContactsContract.Intents.Insert.EMAIL, "[email protected]");
startActivityForResult(intent, INSERT_CONTACT_REQUEST);
this works, but i don't see how to handle multiple types of a given field, say phone number. in the intent, i can put extra a phone number, and i can put extra a phone number type, but how do i put extra an additional phone number, with a different (or perhaps even the same) type?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ContactsContract.Intents.Insert
允许使用PHONE、SECONDARY_PHONE 和 TERTIARY_PHONE
- 这同样适用于EMAIL
,并且建议每个最多三个。我不知道是否可以拥有多个相同“类型”的手机 - 例如,一旦我分配了家庭号码,我的手机联系人编辑器就会从选择列表中删除“家庭”。但是,您可以分配自己的“自定义”类型。例如,假设您的朋友有两个家庭电话号码......
ContactsContract.Intents.Insert
allows forPHONE, SECONDARY_PHONE and TERTIARY_PHONE
- the same applies forEMAIL
and it suggests three of each might be the maximum.I don't know if it's possible to have more than one phone of the same 'type' - my phones contacts editor removes 'Home' from the list of choices once I've assigned a home number for example. You can, however, assign your own 'custom' type. For example, suppose your friend has two home numbers...