2

I am implementing a custom DocumentsProvider. When accessing the file picker using standard Android protocol, the application can provide multiple mime types they are interested in, then request the file picker doing something like this:

        // Use the media type they selected
        intent.putExtra(Intent.EXTRA_MIME_TYPES, mimeTypes);
        intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);

        intent.setType( "*/*");
        startActivityForResult(intent, SELECT_MEDIA_CODE);

When the file picker opens, my custom document provider is shown. What I need to do in that class is be able to detect what the list of mime types was that the app stored in the 'putExtra' line above, so I can load the cursor appropriately in the document providers 'queryChildDocuments' method.

How do I get at the data in the intent that was used to launch the File Picker from within the DocumentsProvider?

tfrysinger
  • 1,306
  • 11
  • 26

1 Answers1

1

That's not possible - you should just return all of the files you have.

The mime types provided to the file picker are used for two purposes:

  • Filtering out DocumentsProviders that have set COLUMN_MIME_TYPES when there's no overlap in mime types
  • Automatically greying out documents of invalid mime types so that they cannot be selected by the user
ianhanniballake
  • 191,609
  • 30
  • 470
  • 443
  • 1
    I now understand that if a value is supplied in the MIME_TYPES column for a roots cursor, then the FilePicker will only show the root if somewhere in their hierarchy the designated mime type is present. _This would be the place where it would be useful to know what the app supplied as the intent to the File Picker._ If I knew that the app supplied "image/*" for example in the intent that launched the File Picker, then I could match it in this column and no root cursors that didn't have this mime type somewhere in their hierarchy would even be shown to the user. – tfrysinger Jul 06 '18 at 17:25
  • 1
    The Documents UI already does the filtering, this isn't something you have to do. Just provide what mime types you have (if you know). – ianhanniballake Jul 06 '18 at 17:28