I think its a problem of Android version 4.0 +.
Just try to remove,
File photo = new File(Environment.getExternalStorageDirectory(), "Pic.jpg");
imageUri = Uri.fromFile(photo);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
When you call Capture intent. Now your resulted bundle onActivityResult()
is not NULL
.
Actually, When you are giving MediaStore.EXTRA_OUTPUT
parameter to Camera Intent then camera application doesn't callback with bundled data. (I find this issues in Android 4.0 +)
You have to get the Image file from Uri which you set as MediaStore.EXTRA_OUTPUT
parameter.
Update:
Or use below pathFromUri()
method and pass Uri which you are set to camera intent and get the Real File Path, now for this you don't have to use Bundle extras = data.getExtras();
private String pathFromUri(Uri imageUri) {
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(imageUri, filePathColumn,
null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
return filePath ;
}