小编Ale*_*ull的帖子

Android意图过滤器问题

我正在尝试编写一个意图过滤器来从联系人列表中选择一个联系人(纯粹出于教育目的......我正在学习意图)。在对隐式意图调用 startActivity 后,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>
Run Code Online (Sandbox Code Playgroud)

这是我如何调用主要活动的隐含意图:

Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse("content://com.android.contacts/contacts"));
startActivityForResult(intent, PICK_CONTACT);
Run Code Online (Sandbox Code Playgroud)

android resolution intentfilter android-intent android-contacts

3
推荐指数
1
解决办法
3096
查看次数