如何正确设置与SHOW_OR_CREATE_CONTACT动作的机器人意图是什么? [英] How to properly set an android intent with the SHOW_OR_CREATE_CONTACT action?

查看:248
本文介绍了如何正确设置与SHOW_OR_CREATE_CONTACT动作的机器人意图是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用内部的联系活动,以创建新的联系人。
这里是code:

 意向书I =新意图();
    i.setAction(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setData(Uri.fromParts(电话,12345678,NULL));
    i.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE,真);
    i.putExtra(ContactsContract.CommonDataKinds.Phone.TYPE,ContactsContract.CommonDataKinds.Phone.TYPE_WORK);
    i.putExtra(ContactsContract.Intents.Insert.EMAILnaoknaoknaok@gmail.com);
    i.putExtra(ContactsContract.CommonDataKinds.Email.TYPE,ContactsContract.CommonDataKinds.Email.TYPE_WORK);
    i.putExtra(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME井);
    i.putExtra(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAMEVele的);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.COMPANY,公司名称);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.TYPE,ContactsContract.CommonDataKinds.Organization.TYPE_WORK);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.LABEL,标签);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.TITLE,职称);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.DEPARTMENT,部);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.JOB_DESCRIPTION,岗位说明书);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.SYMBOL,符号);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.OFFICE_LOCATION,办公地点);

但是,这code只是部分有效。只有电话号码和电子邮件地址中的活性是可见的,其它字段是未固化

下面是从仿真器的截图:
edit_contact1

对不起,不包括它,但我没有足够的声誉,包括图像。

任何帮助将大大AP preciated!

一些更新:下面code设置给定名称字段:

  i.putExtra(ContactsContract.Intents.Insert.NAME,简单的名字);


解决方案

我想像,只有在ContactsContract.Intents.Insert不断的钥匙。*由意向接收器的理解。这将是有意义的。

I would like to use the internal Contact activity to create a new Contact. Here is the code:

        Intent i = new Intent();
    i.setAction(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT);
    i.addCategory(Intent.CATEGORY_DEFAULT);
    i.setData(Uri.fromParts("tel", "12345678", null));
    i.putExtra(ContactsContract.Intents.EXTRA_FORCE_CREATE, true);
    i.putExtra(ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.TYPE_WORK); 
    i.putExtra(ContactsContract.Intents.Insert.EMAIL, "naoknaoknaok@gmail.com");
    i.putExtra(ContactsContract.CommonDataKinds.Email.TYPE, ContactsContract.CommonDataKinds.Email.TYPE_WORK);
    i.putExtra(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, "Ide");
    i.putExtra(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, "Vele");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.COMPANY, "Company name");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.TYPE, ContactsContract.CommonDataKinds.Organization.TYPE_WORK);
    i.putExtra(ContactsContract.CommonDataKinds.Organization.LABEL, "label");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.TITLE, "job title");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.DEPARTMENT, "department");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.JOB_DESCRIPTION, "job description");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.SYMBOL, "symbol");
    i.putExtra(ContactsContract.CommonDataKinds.Organization.OFFICE_LOCATION, "office location");

But this code only partially works. Only the phone number and the email address are visible in the activity, the other fields are unset.

Here is the screenshot from the emulator: edit_contact1

Sorry for not including it, but i don't have enough reputation to include images.

Any help would be greatly appreciated !

Some update: the following code sets the 'Given name' field:

i.putExtra(ContactsContract.Intents.Insert.NAME, "simple name");

解决方案

i'd imagine that only the constant keys in ContactsContract.Intents.Insert.* are understood by the intent receiver. that would make sense.

这篇关于如何正确设置与SHOW_OR_CREATE_CONTACT动作的机器人意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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