Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/222.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何设置意图过滤器,以便仅在发送联系人时发送操作?_Android_Android Intent_Intentfilter - Fatal编程技术网

Android 如何设置意图过滤器,以便仅在发送联系人时发送操作?

Android 如何设置意图过滤器,以便仅在发送联系人时发送操作?,android,android-intent,intentfilter,Android,Android Intent,Intentfilter,我想在我的应用程序上注册一个意向过滤器,这样我就可以将其他应用程序中的联系人共享到我的应用程序中 我已经可以通过将其添加到我的清单中来实现这一点: <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mime

我想在我的应用程序上注册一个意向过滤器,这样我就可以将其他应用程序中的联系人共享到我的应用程序中

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

<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”
,但没有帮助


谢谢

设置
android:host
时,还需要设置
android:scheme
,否则将忽略它。尝试将其设置为android:scheme=“content”。不过,所有这些都会阻止您接受没有包含权限“com.android.contacts”的数据URI的意图


也就是说,您指定的mime类型将接受任何基于文本的内容。这是你的本意吗?也许你应该使用谷歌指定的搜索引擎。

哦,现在我知道了!使用android:mimeType=“text/x-vcard”解决了我的问题!非常感谢!:)@里卡多特罗我也发现了同样的情况。这节省了我的时间,谢谢。