Skip to content

Commit 0d30f65

Browse files
authored
Merge pull request #190 from lennonpetrick/master
Added a method to use the camera
2 parents 9e53d85 + c3ec812 commit 0d30f65

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ buildscript {
33
jcenter()
44
}
55
dependencies {
6-
classpath 'com.android.tools.build:gradle:2.1.3'
6+
classpath 'com.android.tools.build:gradle:2.2.2'
77
}
88
}
99

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImage.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,30 @@ public static Intent getPickImageChooserIntent(@NonNull Context context, CharSeq
194194
return chooserIntent;
195195
}
196196

197+
/**
198+
* Get the main Camera intent for capturing image using device camera app.
199+
* If the outputFileUri is null, a default Uri will be created with {@link #getCaptureImageOutputUri(Context)}, so then
200+
* you will be able to get the pictureUri using {@link #getPickImageResultUri(Context, Intent)}. Otherwise, it is just you use
201+
* the Uri passed to this method.
202+
*
203+
* @param context used to access Android APIs, like content resolve, it is your activity/fragment/widget.
204+
* @param outputFileUri the Uri where the picture will be placed.
205+
*/
206+
public static Intent getCameraIntent(@NonNull Context context, Uri outputFileUri) {
207+
208+
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
209+
210+
if (outputFileUri == null) {
211+
212+
outputFileUri = getCaptureImageOutputUri(context);
213+
214+
}
215+
216+
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
217+
218+
return intent;
219+
}
220+
197221
/**
198222
* Get all Camera intents for capturing image using device camera apps.
199223
*/

0 commit comments

Comments
 (0)