Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - intent match with Content Provider

From reading the Intent documentation, I see that it can be used for starting an Activity, Service or Sending a Broadcast.

I want to ask how Intents are related to Content Providers. I've use calendar and contacts content providers (following Common Intents), but those still use startActivity. I ask because the PackageManager has a API called queryIntentContentProviders, with the comment :

Retrieve all providers that can match the given intent.

I want to ask what are the use cases where an intent is matched against a Content Provider.

like image 215
Jake Avatar asked Aug 02 '26 04:08

Jake


1 Answers

Since this was added as part of API level 19 (KitKat) my guess is that's is used with the Storage Access Framework.

  • The interaction starts when an application (in this example, a photo app) fires the intent ACTION_OPEN_DOCUMENT or ACTION_CREATE_DOCUMENT. The intent may include filters to further refine the criteria—for example, "give me all openable files that have the 'image' MIME type."
  • Once the intent fires, the system picker goes to each registered provider and shows the user the matching content roots.

And the example content provider is defined like this:

    <provider
        android:name="com.example.android.storageprovider.MyCloudProvider"
        ...
        android:enabled="@bool/atLeastKitKat">
        <intent-filter>
            <action android:name="android.content.action.DOCUMENTS_PROVIDER" />
        </intent-filter>
    </provider>

This is the only example of Intent-to-Content-Provider matching that I've seen so far.

Actually, I don't think Content Providers could define intent-filters before, though I might be mistaken.

like image 74
matiash Avatar answered Aug 04 '26 19:08

matiash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!