【问题标题】:Android Intent Action "ACTION_INSERT_OR_EDIT" - should it be used for adding contacts?Android Intent Action“ACTION_INSERT_OR_EDIT” - 应该用于添加联系人吗?
【发布时间】:2011-04-01 00:49:13
【问题描述】:

目前,我正在寻找一种从 SDK 级别 7 开始在 Android 中添加联系人的简单且受支持的方法。(当电话号码等某种数据可用时)我查看了默认联系人应用程序并发现“Intent .ACTION_INSERT_OR_EDIT”,用于从拨号屏幕添加新联系人(或从联系人提供者向联系人添加号码),mime 类型为“vnd.android.cursor.item/person”。 现在很高兴知道如何找到一些关于在使用该操作时应该添加的附加功能的文档,以及它是否是尝试支持尽可能多的手机的正确方法。

我期待着阅读您的想法。非常感谢。

问候。

【问题讨论】:

    标签: android android-sdk-2.1 android-2.2-froyo


    【解决方案1】:

    就 Android 文档的大部分内容而言,原生 Intent 的文档非常少,但此处列出了可用的附加功能:http://developer.android.com/reference/android/provider/ContactsContract.Intents.Insert.html

    这是一个例子:

    Intent intent = new Intent(Intent.ACTION_INSERT_OR_EDIT);
    intent.setType(ContactsContract.Contacts.CONTENT_ITEM_TYPE);
    intent.putExtra(ContactsContract.Intents.Insert.EMAIL, "example@example.com");
    startActivity(intent);
    

    上面的代码应该启动一个活动,让您可以选择要编辑的联系人,并将“example@example.com”作为新电子邮件插入,或者让您创建一个新联系人,并将“example@example.com”插入为电子邮件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-16
      • 1970-01-01
      • 2018-08-08
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      相关资源
      最近更新 更多