System File Picker in 4.4 and 3rd party apps

259 views
Skip to first unread message

Bastian Konetzny

unread,
Mar 12, 2014, 6:05:06 AM3/12/14
to android-...@googlegroups.com
Android 4.4 got a new File Picker UI which is based on apps supporting the Storage Access Framework.

When I open up the Gmail app and add an attachment to my mail, the File Picker UI shows up and displays the local library paths (images, music, video) as well as all apps that manage files (Dropbox, Filemanagers, etc) and I can choose a file from there.

Now I try to implement the same File Picker UI in my own app, using the StorageClient Example (http://developer.android.com/samples/StorageClient/index.html). In this app, I only get the local library paths and the Google Drive app as a source for files. That's also true for any other app using the new File Picker UI like Quickoffice.

Why is showing Gmail more apps to choose from in the same UI than the other apps? Am I missing some options here, or is the File Picker in Gmail a modified version of the System File Picker? It seems that the additionally listed apps in the Gmail File Picker are not supporting Storage Access Framework (yet). Any hints how to accomplisch the same (more complete) File Picker like in the Gmail app in my own custom app?

Jeff Sharkey

unread,
Mar 15, 2014, 8:24:46 PM3/15/14
to android-...@googlegroups.com
The difference you're seeing is based on the intent action used.

In KitKat, the GET_CONTENT intent launches DocumentsUI which offers both SAF providers and intent disambiguation for other apps responding to the GET_CONTENT intent.  (There is a divider shown in the drawer to indicate the separation between these two types.)

When the OPEN_DOCUMENT intent is launched, only SAF providers are shown.  This is because the OPEN_DOCUMENT contract is much stronger than GET_CONTENT, and it can only be implemented by SAF providers.  For example, when using OPEN_DOCUMENT you have write access to returned files, and the ability to persist the Uri permission grant across device boots.

Usually GET_CONTENT is a good choice for "attach" or "transient read access" use-cases.  OPEN_DOCUMENT is a good choice for long-term read/write access.

Hope this helps.  :)

j



--
You received this message because you are subscribed to the Google Groups "android-platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-platfo...@googlegroups.com.
To post to this group, send email to android-...@googlegroups.com.
Visit this group at http://groups.google.com/group/android-platform.
For more options, visit https://groups.google.com/d/optout.



--
Jeff Sharkey
jsha...@android.com
Reply all
Reply to author
Forward
0 new messages