Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show more providers with ACTION_OPEN_DOCUMENT

I want to use the android system dialog provided as part of the Storage Access Framework to open a file. I do this with

Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setType("application/pdf");
startActivityForResult(intent, EDIT_REQUEST);

and then handle the returned URI in onActivityResult().

The problem is that, in the resulting menu, I get far less content providers than I expected. Only Google Drive and Downloads (see left screen shot below). Others, like Dropbox, Solid Explorer,... are not show.

I suspect the reason is that these apps simply don't set the necessary intent filter to show up in this list.

However, other apps, for example Kaiten Mail or Chrome, somehow manage to show the system dialog with fully implemented content providers at the top of the list and then others, like Dropbox and Solid Explorer, below, separated by a thin bar (see the right screen shot).

How can I get this behavior?

Comparison of the behavior I get (left) and the one I want (right)

like image 910
cgogolin Avatar asked Dec 19 '14 14:12

cgogolin


1 Answers

Use 'ACTION_GET_CONTENT:

Intent intent = new Intent(Intent. ACTION_GET_CONTENT);
intent.setType("application/pdf");
startActivityForResult(intent, EDIT_REQUEST);
like image 185
Bogdan Diaconescu Avatar answered Nov 13 '22 04:11

Bogdan Diaconescu