At http://developer.android.com/guide/topics/providers/document-provider.html#manifest it is shown how to register a custom document provider in the 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>
This <intent-filter> element is necessary here, but Android Studio complains with:
Element intent-filter is not allowed here
and the documentation for the provider element seems to indicate so as well:
CAN CONTAIN:
<meta-data>
<grant-uri-permission>
<path-permission>
Is this an Android Studio and documentation bug or am I missing something?
You're not missing anything; Android Studio and the documentation are incorrect. Providers are subject to discovery through intent matching, just like any other component.
Android finds document providers using code like this:
Intent i = new Intent(DocumentsContract.PROVIDER_INTERFACE);
List<ResolveInfo> providers = packageManager.queryIntentContentProviders(i, 0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With