java.lang.Object | ||
↳ | sofia.app.internal.AbsActivityStarter | |
↳ | sofia.content.MediaChooser |
Allows the user to choose a piece of media (such as an image or a video) from the media gallery on his or her device.
This class should be used from an event handler in a Screen
subclass. Display the media chooser by calling the start(Activity)
method. When a selection is made, the mediaWasChosen
method will be
called on the screen, if it exists. For example:
public class MyScreen extends Screen { public void buttonClicked() { MediaChooser chooser = new MediaChooser(); chooser.start(this); } public void mediaWasChosen(MediaChooser chooser) { // Do something with the media by calling chooser.getBitmap(), // chooser.getUri(), or chooser.getPath(). } }
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MediaChooser()
Initializes a new media chooser that, by default, has the content type
image/* . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Bitmap |
getBitmap()
A convenience method that returns the chosen image as a
Bitmap
if the selected media was an image. | ||||||||||
String |
getPath()
Gets the file system path of the media that was chosen in the media
chooser.
| ||||||||||
String |
getType()
Gets the content type of the acceptable kinds of media that can be
selected by this media chooser.
| ||||||||||
Uri |
getUri()
Gets the
Uri (uniform resource identifier) of the media that was
chosen in the media chooser. | ||||||||||
void | handleActivityResult(Activity owner, Intent data, int requestCode, int resultCode) | ||||||||||
void |
setType(String newType)
Sets the content type (also known as the MIME type or internet media type) of the acceptable kinds of media that can be selected by this media chooser. | ||||||||||
void |
start(Activity owner, String method)
Starts the media chooser.
| ||||||||||
void |
start(Activity owner)
Starts the media chooser.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | getDefaultCallback() |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
sofia.app.internal.AbsActivityStarter
| |||||||||||
From class
java.lang.Object
|
Initializes a new media chooser that, by default, has the content type
image/*
.
A convenience method that returns the chosen image as a Bitmap
if the selected media was an image. Otherwise, the method returns null.
Bitmap
that represents the image that was chosen, or
null if it was not an image
Gets the file system path of the media that was chosen in the media chooser.
Gets the content type of the acceptable kinds of media that can be selected by this media chooser.
Sets the content type (also known as the MIME type or internet media
type) of the acceptable kinds of media that can be selected by this
media chooser. This content type can be a specific individual type
(such as image/jpeg
) or include a wildcard to support multiple
related types (e.g., image/*
or video/*
).
More information about content types can be found in the Wikipedia article Internet media types.
newType | the MIME type for this media chooser |
---|
Starts the media chooser. When the user has chosen an item from the
media gallery, the owning Activity
(or Screen
) will
have the method with the name specified by method
called.
owner | the activity or screen that owns this media chooser and will receive a notification when a media item is chosen |
---|---|
method | the name of the method that will be called on
owner when a media item is chosen
|
Starts the media chooser. When the user has chosen an item from the
media gallery, the owning Activity
(or Screen
) will
have its mediaWasChosen
method called.
owner | the activity or screen that owns this media chooser and will receive a notification when a media item is chosen |
---|