插入一个新的联系人意图 [英] Insert a new contact intent

查看:134
本文介绍了插入一个新的联系人意图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我的应用程序之一,我需要的用户选择他现有的联系人之一或创建一个新的。 选择其中的一个显然是容易做到以下code:

For one of my apps, I need the user to select one of his existing contacts or to create a new one. Picking one is clearly easy to do with the following code:

i = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
startActivityForResult(i, PICK_CONTACT_REQUEST );

现在我想创建一个新的联系人。我试着使用code,但它不会触发活动的结果是:

Now I want to create a new contact. I tried to use that code but it doesn't trigger the activity result:

i = new Intent(Intent.ACTION_INSERT);
i.setType(Contacts.CONTENT_TYPE);
startActivityForResult(i, PICK_CONTACT_REQUEST);

以上code将开始接触添加表格。然后,当我验证它,它只是要求我打开联系人列表和onActivityResult方法不会被触发。

The above code will start the contact adding form. Then when I validate it, it just asks me to open the contact list and the onActivityResult method is never triggered.

你能不能帮我做它的工作?

Could you help me to make it working ?

我读了一些电路板,这是不可能的,我不得不创建我自己的联系人添加表格。你能否证实?

I read on some boards that this wasn't possible, and I had to create my own contact adding form. Could you confirm that ?

编辑:问题解决了。检查我的答案。

推荐答案

终于找到了一个解决方案,我与你分享。 仅这对于Android版本4.0.3以上及副修复。它不上4.0到4.0.2工作

Finally found a solution, I'm sharing it with you. That's only a fix for Android version above 4.0.3 and sup. It doesn't work on 4.0 to 4.0.2.

i = new Intent(Intent.ACTION_INSERT);
i.setType(Contacts.CONTENT_TYPE);
if (Integer.valueOf(Build.VERSION.SDK) > 14)
    i.putExtra("finishActivityOnSaveCompleted", true); // Fix for 4.0.3 +
startActivityForResult(i, PICK_CONTACT_REQUEST);

这篇关于插入一个新的联系人意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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