I have a fatal error occurring in my onActivityResult returning from camera activity. What I scratch my head is that the error only occurs on a few phones (depending on the number of users affected), although for most there is nothing wrong. I can duplicate the error on my Nexus 6 (Lollipop 5.1.1 works), while my note 5 (also 5.1.1) has no problems at all.
The problem is that I am trying to assign imageUri from data.getData (). Debugging on note 5, data.mData is "content: // media / external / images / media / 2215", and on Nexus 6, data.mData is null.
I know this is a general question asked on SO, but so far I have not found anything that helped me. Can someone point me to this solution and give an answer?
Method Trigger the camera action for the result
@OnClick(R.id.change_image_camera) public void takePicture(){
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);}
onActvityResult
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == Activity.RESULT_OK) {
Uri imageUri = data.getData();
String realPath = Image.getPath(this, imageUri);
Image.compressImage(realPath);
File file = new File(realPath);
Bundle extra = new Bundle();
extra.putString("URL", realPath);
returnIntent.putExtras(extra);
setResult(RESULT_OK, returnIntent);
finish();
}
}
I really appreciate any help with this!
source
share