This question already has an answer here:
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?
A bit late this answer but I had this same problem just now and I found a solution:
Hope it helps!