【问题标题】:How to open add contact page in android from a mobile browser如何从移动浏览器在 android 中打开添加联系人页面
【发布时间】:2019-07-25 08:54:04
【问题描述】:

我想让用户能够直接从我的网站添加联系人。我知道我们无法从浏览器访问通讯录,但我找不到任何关于如何将用户重定向到预填充的添加联系人页面的资源。

我遇到了 chrome intent https://developer.chrome.com/multidevice/android/intents,但不知道如何将它们用于联系人。

【问题讨论】:

  • 您找到任何可行的解决方案了吗?

标签: android android-contacts android-chrome


【解决方案1】:

我认为您链接到的官方文档在意图部分 type 中缺少另一项。

您想在 Java 中调用的意图是:

Intent intent = new Intent(ContactsContract.Intents.Insert.ACTION);
intent.setType(ContactsContract.Contacts.CONTENT_TYPE);

如果我们将常量翻译成文字,那就是:

Intent intent = new Intent("android.intent.action.INSERT");
intent.setType("vnd.android.cursor.dir/contact");

如果我们现在将其转换为 chrome 的 Android 意图方案,那就是:

var url = "intent:#Intent;action=android.intent.action.INSERT;type=vnd.android.cursor.dir/contact;end"

请注意,您必须有用户交互才能让 Android 上的 Chrome 调用此 Intent,因此它需要位于按钮或类似内容中才能使其工作(直接在地址栏上键入也不行)

【讨论】:

    猜你喜欢
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多