Android: "Element intent-filter is not allowed here" 在 <provider> 里面?

Android: "Element intent-filter is not allowed here" inside <provider>?

http://developer.android.com/guide/topics/providers/document-provider.html#manifest 展示了如何在清单中注册自定义文档提供程序:

<manifest... >
    ...
    <uses-sdk
        android:minSdkVersion="19"
        android:targetSdkVersion="19" />
        ....
        <provider
            android:name="com.example.android.storageprovider.MyCloudProvider"
            android:authorities="com.example.android.storageprovider.documents"
            android:grantUriPermissions="true"
            android:exported="true"
            android:permission="android.permission.MANAGE_DOCUMENTS"
            android:enabled="@bool/atLeastKitKat">
            <intent-filter>
                <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
            </intent-filter>
        </provider>
    </application>

</manifest>

元素在这里是必需的,但 Android Studio 抱怨:

Element intent-filter is not allowed here

the documentation for the provider element 似乎也表明了这一点:

CAN CONTAIN:
<meta-data> 
<grant-uri-permission> 
<path-permission>

这是 Android Studio 和文档错误还是我遗漏了什么?

你没有遗漏任何东西; Android Studio 和文档不正确。与任何其他组件一样,提供程序可以通过意图匹配进行发现。

Android 使用如下代码查找文档提供者:

Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE);

List<ResolveInfo> providers = packageManager.queryIntentContentProviders(i, 0);