I'm trying to get image from the camera or the gallery (whatever the user chose) in one intent. the problem is that I always get intent.getData()
as null in OnActivityResult
.
I'm doing the following as suggested here:
Intent pickIntent = new Intent();
pickIntent.setType("image/*");
pickIntent.setAction(Intent.ACTION_GET_CONTENT);
Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
String pickTitle = "Select or take a new Picture"; // Or get from strings.xml
Intent chooserIntent = Intent.createChooser(pickIntent, pickTitle);
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { takePhotoIntent });
startActivityForResult(chooserIntent, SELECT_PICTURE);
OnActivityResult:
if (requestCode == SELECT_PICTURE && resultCode == Activity.RESULT_OK) {
if (data != null) {
try {
final Uri imageUri = data.getData();
Log.e("uri", imageUri + "");
uri is null