public class MediaUtils
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static int |
CAPTURE_PHOTO_REQUEST_CODE
Constants
|
static int |
PICK_MEDIA_REQUEST_CODE |
| Constructor and Description |
|---|
MediaUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
cleanFilename(java.lang.String fileName)
Clean the extension off of the file name.
|
static android.content.Intent |
getCameraCaptureIntent(android.content.Context ctx,
java.lang.String authority)
Generate the appropriate intent to launch the existing camera application
to capture an image
|
static android.content.Intent |
getChooseMediaIntent(java.lang.String mimeType)
Generate the appropriate intent to launch the document chooser to allow the user
to pick an image to upload.
|
static <any> |
handleActivityResult(android.content.Context context,
int resultCode,
int requestCode,
android.content.Intent data)
Handle the activity result of an intent launched to capture a photo or choose an image
|
static java.io.File |
nonDuplicateFile(java.io.File dir,
java.lang.String name)
Create a non duplicate file in the given directory with the given name, appending a duplicate
counter to the end of the name but before the extension like: `some_file(1).jpg`
|
public static final int CAPTURE_PHOTO_REQUEST_CODE
public static final int PICK_MEDIA_REQUEST_CODE
public static android.content.Intent getCameraCaptureIntent(android.content.Context ctx,
java.lang.String authority)
CAPTURE_PHOTO_REQUEST_CODEpublic static android.content.Intent getChooseMediaIntent(java.lang.String mimeType)
mimeType - the MIME type you want to constrict the chooser toPICK_MEDIA_REQUEST_CODEpublic static <any> handleActivityResult(android.content.Context context,
int resultCode,
int requestCode,
android.content.Intent data)
context - the activity contextresultCode - the result of the return coderequestCode - the request code that launched the activity that caused the resultdata - the data from the resultgetCameraCaptureIntent(Context, String),
getChooseMediaIntent(String)public static java.lang.String cleanFilename(java.lang.String fileName)
fileName - the full file namepublic static java.io.File nonDuplicateFile(java.io.File dir,
java.lang.String name)
dir - The parent directory of the desired filename - The desired name of the file