by fattire · 7y ago · 0 comments
https://developer.android.com/guide/topics/providers/documen...
Best part-- along with the URI, you get the permission to access the document/file/image/audio/whatever "for free" without ever having to request it! Because you kind of just did-- the act of the user picking the file auto-gives you the read permission, which can be kept ("persisted") across system/app restarts.
This file may not even be on the actual device. It could be on some cloud service or a file server or something else you've never even heard of. Android handles it all for you. An example of this is Google Drive. If they've installed the Google Drive app and it's linked to their account, the Storage Access Framework will let the user pick stuff from there just as easily as their own external storage.
You can also use the picker to create/save a new file or even choose a whole (directory/folder) tree.
Reading from the content:// URI is a little different than from a file:// , and I know there are some situations where this won't cut it. But starting in Q you'll be kind of limited in where those files can be accessed.
But in most situations involving External Storage, the SAF is really what you want to use anyway.
Watch this little-seen video:
Or not. A File Picker does not work for playlists, linked MKV/MOV files, subtitles autodetection (subfolders and such), and so many other multimedia cases.
Also, it is a pain to use from the NDK... And incorrectly documented.
And then, the UI to allow people to give you access to the folders is extremely confusing, hard to explain to users, not customizable, and changes from version of Android to another, so very hard to document.
Exactly. HTML files are another victim of this, as with content://-URIs there's no official way to properly resolve relative URIs for any subresources (images, style sheets, scripts and whatnot) or local links, and even if you could, you wouldn't have the permission to access those files anyway. Even Android's included mini HTML-viewer app (or Chrome for that matter) are broken if you try viewing a HTML file using a content://-URI, e.g. from the file explorer that's built-in since Marshmallow.
I opened https://issuetracker.google.com/issues/77406791 for that, but you can guess at the reply I received so far (none - I guess I should be glad they didn't close it outright...)
And another problem is that even if your app has the appropriate storage permissions itself (whether through READ_EXTERNAL_STORAGE or the new-fangled way, even if that means dealing with the SAF) and could therefore open both that file and its companion resources without relying on the permissions attached to the content://-URI intent, in practice that's rather difficult because even for local files there's no official link between the content://-URI and the file system location. In practice at least some ContentProviders will leak the path through the URI, allowing you to reconstruct the original file path with a little luck, but that's of course not really a reliable method.
In the case of a sophisticated media player like VLC I totally get your point. The solution before Q was just to ask for the READ/WRITE storage permissions and have full access. I guess they figure that's too broad access for one app to have.
Upsides-- it works great on Chromebooks, integrating with ChromeOS well, and the convenience of seamlessly integrating a single UI with numerous cloud services with no extra SDKs to include or APIs to learn is also a big plus.
Granted, I only do that on a phome in a pinch but having these features saved me more than once. I dom't want Android to become as restrictive and underpowered as iOS feels to me.
Alternatively, the app can register itself as opener of zip files, then it could extract them freely to its own private directory (without asking for permissions) and let you list and upload them.
I haven't found the reading part to be different, but getting the uri has changed from Uri.fromFile() to their FileProvider package. Which, requires quite a bit of setup in comparison.
To be fair, it's documented well on the Android developer site.
[0] https://developer.android.com/reference/android/media/ExifIn...
This is not a good thing for VR apps. Unless there's a VR system file picker in the works that I'm unaware of..
Suppose you're a VR app and you invoke a picker to open a... I don't know... you want to open a sound file. How should the picker's UI be to fit into your general VR interface?
If a sound file is particularly badly suited, then some other kind of file (but in that case I'm interested in why that's easier/better than sound).
The crucial point is to remain inside the stereoscopic VR view since exiting VR is very disruptive.
I’m afraid a general Android VR item picker will be a lot more boring though.