@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); filePath = getOutputMediaFile(FileColumns.MEDIA_TYPE_IMAGE); File file = new File(filePath); Uri output = Uri.fromFile(file); Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); i.putExtra(MediaStore.EXTRA_OUTPUT, output); startActivityForResult(i, RETURN_FILE_PATH); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data);
I checked the values ββfor the Uri file and output , both of them are beautiful, and the captured image really exists in this place .
But the data returned in onActivityResult is always null even after image capture.
EDIT:
I checked this question:
onActivityResult returns with data = null
which reads:
Whenever you save an image by passing EXTRAOUTPUT with the intent of the camera, the data parameter inside onActivityResult always returns null. So, instead of using data to extract the image, use the file path to get the bitmap.
and maybe this solution will work for me. But the above code has been working code so far in the same scenario.
android onactivityresult
Archie.bpgc
source share