gpt4 book ai didi

android - 如何仅在发送联系人时设置 Intent 过滤器以发送操作?

转载 作者:搜寻专家 更新时间:2023-11-01 09:11:44 24 4
gpt4 key购买 nike

我想在我的应用程序上注册一个 intent-filter,这样我就可以将其他应用程序中的联系人分享给我。

我已经可以通过将其添加到我的 list 中来实现这一点:

<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/*" />
</intent-filter>

问题是我的应用程序出现在共享文本数据的其他应用程序的所有“共享”或“发送到”弹出窗口中。我该如何限制这一点,以便我的应用仅出现在联系人共享弹出窗口中?

我已经尝试使用 android:host="com.android.contacts"里面<data>但没有帮助。

谢谢!

最佳答案

当你设置一个android:host时,你还需要设置一个android:scheme,否则它会被忽略。尝试将其设置为 android:scheme="content"。但是,所有这一切都会阻止您接受没有包含权限“com.android.contacts”的数据 URI 的 Intent 。

也就是说,您指定的 mime 类型将接受任何基于文本的内容。那是你想要的吗?也许你应该使用 contact item mime-type由 Google 指定。

关于android - 如何仅在发送联系人时设置 Intent 过滤器以发送操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7828759/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com