muzei-api / com.google.android.apps.muzei.api.provider / MuzeiArtDocumentsProvider / <init>

<init>

MuzeiArtDocumentsProvider()

An implementation of DocumentsProvider that provides users direct access to the images of one or more MuzeiArtProvider instances.

Linking a MuzeiArtProvider to MuzeiArtDocumentsProvider

Each MuzeiArtProvider has an authority associated with it, which uniquely defines it across all apps. This means it should generally be namespaced similar to your application ID - i.e., com.example.artprovider.

A MuzeiArtDocumentsProvider uses the android:authorities assigned to it as the mechanism for linking it to a single MuzeiArtProvider instances from your app - the authority used must be that of a valid MuzeiArtProvider plus the suffix .documents. For example, if your MuzeiArtProvider had the authority of com.example.artprovider, you would use an authority of com.example.artprovider.documents:

<provider android:name="com.google.android.apps.muzei.api.provider.MuzeiArtDocumentsProvider"
  android:authorities="com.example.artprovider.documents"
  android:exported="true"
  android:grantUriPermissions="true"
  android:permission="android.permission.MANAGE_DOCUMENTS">
  <intent-filter>
      <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
  </intent-filter>
</provider>

The MuzeiArtDocumentsProvider will automatically make the artwork from the MuzeiArtProvider available via the system file picker and Files app.

Subclassing MuzeiArtDocumentsProvider

Android enforces that a single android:name can only be present at most once in the manifest. While in most cases this is not an issue, it does mean that only a single MuzeiArtDocumentsProvider class can be added to the final merged application manifest.

Therefore in cases where you do not control the final application manifest (e.g., when providing a MuzeiArtProvider and MuzeiArtDocumentsProvider pair as part of a library), it is strongly recommended to subclass MuzeiArtDocumentsProvider, ensuring that the android:name in the manifest is unique.

class MyArtDocumentsProvider : MuzeiArtDocumentsProvider()

It is not necessary to override any methods in MuzeiArtDocumentsProvider.

Supporting multiple MuzeiArtProvider instances in your app

Each MuzeiArtDocumentsProvider is associated with a single MuzeiArtProvider via the android:authorities attribute. To support multiple MuzeiArtProvider instances in your app, you must subclass MuzeiArtDocumentsProvider (as described above) and add each separate instance to your manifest, each with the appropriate authority.