onActivityResult returned from a camera, Intent null

前端 未结 7 747
执念已碎
执念已碎 2020-12-06 04:41

I follow the instruction on Camera on Android dev site

I just start the Camera Intent, not build my own camera.

The sample code to handle result return afte

7条回答
  •  独厮守ぢ
    2020-12-06 05:34

    Here is the answer from a similar question. It seems like it might be a problem with Samsung phones...

    Basically, if you have code like this which creates the Intent:

    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    
    fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); // create a file to save the image
    intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
    
    // start the image capture Intent
    startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    

    Then, in onActivityResult, replace data.getData() with fileUri.toString() and it will solve your problem.

提交回复
热议问题