From c3ec81200d733f391c03f6e49e035c9751d94b1a Mon Sep 17 00:00:00 2001 From: Lennon Petrick Spirlandelli Date: Wed, 2 Nov 2016 14:18:05 -0200 Subject: [PATCH] Added a method for creating an intent just to use the camera with the possibility of choosing where to place the picture, so that being able to get easily further --- build.gradle | 2 +- .../theartofdev/edmodo/cropper/CropImage.java | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 857aec95..c1c484e2 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.1.3' + classpath 'com.android.tools.build:gradle:2.2.2' } } diff --git a/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java b/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java index 38b1baee..81f9d1f7 100644 --- a/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java +++ b/cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java @@ -191,6 +191,30 @@ public static Intent getPickImageChooserIntent(@NonNull Context context, CharSeq return chooserIntent; } + /** + * Get the main Camera intent for capturing image using device camera app. + * If the outputFileUri is null, a default Uri will be created with {@link #getCaptureImageOutputUri(Context)}, so then + * you will be able to get the pictureUri using {@link #getPickImageResultUri(Context, Intent)}. Otherwise, it is just you use + * the Uri passed to this method. + * + * @param context used to access Android APIs, like content resolve, it is your activity/fragment/widget. + * @param outputFileUri the Uri where the picture will be placed. + */ + public static Intent getCameraIntent(@NonNull Context context, Uri outputFileUri) { + + Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); + + if (outputFileUri == null) { + + outputFileUri = getCaptureImageOutputUri(context); + + } + + intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri); + + return intent; + } + /** * Get all Camera intents for capturing image using device camera apps. */