This question already has an answer here:
- Getting Uri Null in capture photo from camera intent in samsung mobile 3 answers
I am debugging my app in 2 different physical devices:
- Motorola Moto G, Android 4.4.2
- LG OPTIMUS L5 II, Android 4.1.2
I am calling the camera in a button:
buttonCamera.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
}
});
And I manage the intent result like this:
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Uri selectedImage = data.getData(); // <-- Sometimes null
}
The problem here is that data.getData()
is null in the Motorola Moto G but not in the LG OPTIMUS, why is this? How can I avoid to get null in the Motorola Moto G?