【发布时间】:2020-07-12 23:01:19
【问题描述】:
Flutter for Android developers 文档解释了如何让 Flutter 应用接受传入的 Android Intent,并给出了接受 Share Intent 的代码示例。我已经复制了它,效果很好。
但我现在正试图让我的应用接受其他类型的意图,特别是编辑联系人意图,这样当我使用默认的电话应用并点击在联系人上,建议我的应用完成操作。
我已经尝试了<intent-filter> 的所有可能组合,我在谷歌搜索和搜索 GitHub 后可以找到,但没有任何东西可以让它工作。举几个例子:
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.item/person"/>
<data android:mimeType="vnd.android.cursor.item/contact"/>
<data android:mimeType="vnd.android.cursor.item/raw_contact"/>
<data android:mimeType="vnd.android.cursor.item/phone"/>
<data android:mimeType="vnd.android.cursor.item/phone_v2"/>
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.GET_CONTENT"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="vnd.android.cursor.item/person" android:host="contacts"/>
<data android:mimeType="vnd.android.cursor.item/contact" android:host="contacts"/>
<data android:mimeType="vnd.android.cursor.item/raw_contact" android:host="contacts"/>
</intent-filter>
<intent-filter >
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<data
android:host="contacts"
android:mimeType="vnd.android.cursor.item/person" />
<data
android:host="com.android.contacts"
android:mimeType="vnd.android.cursor.item/contact" />
<data
android:host="com.android.contacts"
android:mimeType="vnd.android.cursor.item/raw_contact" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.APP_CONTACT"/>
</intent-filter>
etc.
我做错了什么?
【问题讨论】:
-
您好,这可能对您有所帮助,请查看以下 URL:muetsch.io/how-to-receive-sharing-intents-in-flutter.html
标签: android flutter android-intent android-contacts