我正在尝试编写一个意图过滤器来从联系人列表中选择一个联系人(纯粹为了教育目的......我正在学习意图)。在隐式意图调用startActivity之后,android应该找到我的自定义活动以及作为候选活动的默认活动,并让我选择我想使用哪一个(intent resolution)。Android意图过滤器问题
但是,使用我目前的设置,它会打开android的默认联系人选择器,而不会给我选择。这是我的意图过滤器。
<activity android:name=".ContactPicker" android:label="PICKER" >
<intent-filter>
<action android:name="android.intent.action.PICK" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" android:host="com.android.contacts" android:path="contacts" />
</intent-filter>
</activity>
,这里是我如何打电话的主要活动隐含的意图:
Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://com.android.contacts/contacts"));
startActivityForResult(intent, PICK_CONTACT);
您需要使用ACTION_CHOOSER这里记录的http://开发商。 android.com/reference/android/content/Intent.html#ACTION_CHOOSER - 抱歉,我不知道如何自己使用它,但尝试谷歌搜索的例子。 – Squonk
@MisterSquonk:如果用户为这个“Intent”选择了一个默认处理程序,那将是必要的。可以想象,内置的联系人应用程序已预先确定为默认设置,但我会感到惊讶,因为他们不会为我尝试覆盖的任何其他“内容”(例如,替代主屏幕)。 – CommonsWare