java.lang.Object | |
↳ | sofia.content.MediaUtils |
Utility methods to make working with the built-in Android media gallery easier for students. TODO These might benefit from some refactoring now.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static List<Uri> |
getExternalMediaUris(ContentResolver resolver, String type)
Gets a list of all external media (stored on the device's SD card) that has the specified type. | ||||||||||
static String |
pathForMediaUri(ContentResolver resolver, Uri uri)
Converts a media
Uri , such as one received by an activity's
onActivityResult method after popping up an image chooser, to
a path on the device's file system that can be used to open or
manipulate the media file. | ||||||||||
static Uri |
uriForMediaWithFilename(ContentResolver resolver, String filename)
Most students will never need to call this method -- it is intended for internal and advanced usage. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Gets a list of all external media (stored on the device's SD card) that
has the specified type. The type can be a complete MIME type (such as
"image/jpeg"
) or one with a wildcard (such as "image/*"
to select all images).
The list returned by this method contains Uri
objects; in order
to get the path that corresponds to that Uri
so that you can
open the file, pass it to the
pathForMediaUri(ContentResolver, Uri)
method.
resolver | the content resolver used to find the content; this can
be obtained by calling getContentResolver() from within the
activity |
---|---|
type | the MIME type of the media to list |
List
containing the Uri
s of all the matching
media on the device's external storage
Converts a media Uri
, such as one received by an activity's
onActivityResult
method after popping up an image chooser, to
a path on the device's file system that can be used to open or
manipulate the media file.
resolver | the content resolver used to find the content; this can
be obtained by calling getContentResolver() from within the
activity |
---|---|
uri | the Uri that represents the location of the media to
get the path for |
Uri
, or
null if the Uri
was invalid
Most students will never need to call this method -- it is intended for internal and advanced usage.
Gets a Uri
that represents a media item with the specified
filename.
No MIME type is required here because the filename of the media (for example, "foo.jpg" or "bar.png") would typically also distinguish the type. However, if multiple media have the same filename, only the first one that is found will be returned, and the ordering of what is "first" is entirely dependent on the internal database ordering, and therefore should not be relied upon. If this is a problem, use a longer path segment than just the filename.
resolver | the content resolver used to find the content; this can
be obtained by calling getContentResolver() from within the
activity |
---|---|
filename | the filename of the media to find |
Uri
that represents the media being requested, or null
if no media with that filename could be found