public class ImageIntent extends ContentIntent<ImageIntent>
ContentIntent implementation providing API for building and starting of intents to obtain
or preview an image content.| Modifier and Type | Class and Description |
|---|---|
static class |
ImageIntent.ImageOptions
Simple options for
processResultIntent(int, int, Intent, Context, ImageOptions). |
ContentIntent.ContentHandler| Modifier and Type | Field and Description |
|---|---|
static String |
IMAGE_FILE_NAME_FORMAT
Default format for image file name.
|
static int |
REQUEST_CODE_CAMERA
Flag to identify request code used to obtain image using camera.
|
static int |
REQUEST_CODE_GALLERY
Flag to identify request code used to obtain image from gallery.
|
CONTENT_FILE_TIME_STAMP_FORMAT| Constructor and Description |
|---|
ImageIntent() |
| Modifier and Type | Method and Description |
|---|---|
static Intent |
createCameraIntent()
Same as
createCameraIntent(File) with null for outputFile parameter. |
static Intent |
createCameraIntent(File outputFile)
Same as
createCameraIntent(Uri) with outputUri created from the given
outputFile if not nul. |
static Intent |
createCameraIntent(Uri outputUri)
Creates a new instance of Intent with
MediaStore.ACTION_IMAGE_CAPTURE that can be used
to launch a camera app to capture a single image. |
static Intent |
createGalleryIntent()
Creates a new instance of Intent with
Intent.ACTION_GET_CONTENT and MimeType.IMAGE
MIME type that can be used to launch a gallery app (depends on user's choice) to pick one of
available images. |
static File |
createImageFile()
Same as
createImageFile(String) with fileName in IMAGE_FILE_NAME_FORMAT
format with a string representation of the current time stamp obtained via ContentIntent.createContentFileTimeStamp(). |
static File |
createImageFile(String fileName)
Same as
ContentIntent.createContentFile(String, String) with .jpg suffix for the specified
fileName (if it does not contain any) and Environment.DIRECTORY_PICTURES as
externalDirectoryType. |
ImageIntent |
input(Uri uri)
If the passed uri is not
null, the current data (MIME) type will be set
by default to MimeType.IMAGE. |
protected ContentIntent.ContentHandler |
onCreateCameraHandler(Resources resources)
Invoked from
withDefaultHandlers(Context) to create camera intent handler. |
protected ContentIntent.ContentHandler |
onCreateGalleryHandler(Resources resources)
Invoked from
withDefaultHandlers(Context) to create gallery intent handler. |
ImageIntent |
output(Uri uri)
Sets an output uri for an image to be captured by the camera.
|
ImageIntent |
withDefaultHandlers(Context context)
Adds two default
ContentHandlers. |
build, createContentFile, createContentFile, createContentFileTimeStamp, dataType, dataType, ensureCanBuildOrThrow, handlers, input, onBuild, onShowChooserDialog, onStartWith, output, startWith, uri, withHandler, withHandlers, withHandlersactivityNotFoundMessage, activityNotFoundMessage, cannotBuildIntentException, dialogTitle, dialogTitle, enterTransition, enterTransition, exitTransition, exitTransition, isActivityForIntentAvailable, notifyActivityNotFound, transitionspublic static final int REQUEST_CODE_GALLERY
public static final int REQUEST_CODE_CAMERA
public static final String IMAGE_FILE_NAME_FORMAT
Constant value: IMAGE_%s
public static Intent createGalleryIntent()
Intent.ACTION_GET_CONTENT and MimeType.IMAGE
MIME type that can be used to launch a gallery app (depends on user's choice) to pick one of
available images.public static Intent createCameraIntent()
createCameraIntent(File) with null for outputFile parameter.public static Intent createCameraIntent(File outputFile)
createCameraIntent(Uri) with outputUri created from the given
outputFile if not nul.outputFile - The desired file used to crate the output Uri.createCameraIntent()public static Intent createCameraIntent(Uri outputUri)
MediaStore.ACTION_IMAGE_CAPTURE that can be used
to launch a camera app to capture a single image.outputUri - If not null, it will be attached to intent as MediaStore.EXTRA_OUTPUT,
so when the result is received in for example Activity.onActivityResult(int, int, Intent),
the outputUri will address to a file which contains the currently
captured image.createCameraIntent(File)public static File createImageFile()
createImageFile(String) with fileName in IMAGE_FILE_NAME_FORMAT
format with a string representation of the current time stamp obtained via ContentIntent.createContentFileTimeStamp().public static File createImageFile(String fileName)
ContentIntent.createContentFile(String, String) with .jpg suffix for the specified
fileName (if it does not contain any) and Environment.DIRECTORY_PICTURES as
externalDirectoryType.fileName - The desired name for the image file.createImageFile()public ImageIntent withDefaultHandlers(Context context)
ContentHandlers. One for REQUEST_CODE_GALLERY and second one
for REQUEST_CODE_CAMERA.withDefaultHandlers in class ContentIntent<ImageIntent>protected ContentIntent.ContentHandler onCreateGalleryHandler(Resources resources)
withDefaultHandlers(Context) to create gallery intent handler.
This method may be override to create a handler with a localized name.
resources - Application resources.onCreateCameraHandler(Resources)protected ContentIntent.ContentHandler onCreateCameraHandler(Resources resources)
withDefaultHandlers(Context) to create camera intent handler.
This method may be override to create a handler with a localized name.
resources - Application resources.onCreateGalleryHandler(Resources)public ImageIntent input(Uri uri)
null, the current data (MIME) type will be set
by default to MimeType.IMAGE.input in class ContentIntent<ImageIntent>uri - The desired uri, which should be delivered to the handling activity. May be
null to clear the current one.ContentIntent.uri()public ImageIntent output(Uri uri)
output in class ContentIntent<ImageIntent>uri - If not null, it will be attached to ContentHandler
holding intent with the REQUEST_CODE_CAMERA request code, so when the camera
handler's item is selected within a chooser dialog and user confirms his
captured photo, result for this action will be received in for example
Activity.onActivityResult(int, int, Intent). The passed
uri will then address to a file which contains the currently captured
image.ContentIntent.uri()