Storage Access Framework, Missing in Action
Google has been using carrots (e.g., sample code) and sticks (e.g.,
ban on the
to get developers to work with content over files. Part of that is
using the Storage Access Framework, which is dominated by three
ACTION_OPEN_DOCUMENT_TREE. Google wants us to be using those for
requesting content from the user, rather than working solely with the
Hence, it would be really helpful if activities existed for those
actions on all relevant devices (Android 4.4+, except for
which is Android 5.0+). For example, they might have part of Compatibility
Test Suite test these actions, so that devices would not ship with broken
Alas, this does not appear to be the case.
In particular, it is a mixed bag on Android TV. Some devices, like the NVIDIA Shield TV, support the Storage Access Framework. Others, such as the Xiaomi Mi Box, do not. Michael Sotnikov, who brought this to my attention, indicates that other Android TV devices behave like the Mi Box.
What’s worse is that it is difficult for us to determine which devices are affected.
That’s because, technically,
are supported… by activities that do nothing other than show a “You don’t have
an app that can do this”
So, not only does the documentation provide no hint that these activities are
optional, but our standard detection mechanisms — such as calling
PackageManager and seeing if it returns
null — do not work.
At least for the Mi Box,
ACTION_OPEN_DOCUMENT_TREE is not supported in the
traditional way, by simply not having an activity for it. Hence, you can check
to see if that
Intent resolves and take steps to work around the problem.
ACTION_CREATE_DOCUMENT, you can check to see
resolveActivity() returns a
ResolveInfo pointing at an activity whose
com.google.android.tv.frameworkpackagestubs package seems to be a stock
Google package — bundled into a
FrameworkStubs.apk file — that
provides these fake implementations. It seems like a variety of Android TV
devices ship with this, perhaps lining up with the devices that Mr. Sotnikov
So, Google decided to not support the Storage Access Framework on some Android TV devices, and failed to document this.
I filed an issue to try to argue that things should move in the other direction, with the CTS confirming the existence of working Storage Access Framework activities, lest we find ourselves with a growing fleet of devices with broken implementations.
Regardless, at least if you are supporting Android TV, have a fallback plan for devices lacking the Storage Access Framework. For example, there are many file chooser libraries for Android; one or more of them may offer a reasonable user experience on a TV.
Need Android app development training for your team? Mark Murphy has trained hundreds! Learn more!