? The http://developer.android.com/guide/topics/providers/document-provider.h...">

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

The http://developer.android.com/guide/topics/providers/document-provider.html#manifest shows how to register a custom document provider in a 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 <target filter> element is needed here, but Android Studio complains about:

Element intent filter not allowed here

and the documentation for the provider item also points to this:

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

Is this Android Studio and a bug in the documentation, or am I missing something?

+5
source share
1 answer

You have not missed anything; Android Studio and the documentation are incorrect. Suppliers can be discovered by matching goals, just like any other component.

Android finds document providers using this code:

Intent i = new Intent ( DocumentsContract.PROVIDER_INTERFACE );

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

+4
source

Source: https://habr.com/ru/post/1247671/


All Articles