I am getting null in contenturi in samsung phones while capturing photo from camera but rest of others phones its working fine.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try
{
if (requestCode == IMAGE_CAPTURE) {
if (resultCode == RESULT_OK){
Uri contentUri = data.getData();
if(contentUri!=null)
{
String[] proj = { MediaStore.Images.Media.DATA };
Cursor cursor = managedQuery(contentUri, proj, null, null, null);
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
imageUri = Uri.parse(cursor.getString(column_index));
}
tempBitmap = (Bitmap) data.getExtras().get("data");
mainImageView.setImageBitmap(tempBitmap);
isCaptureFromCamera = true;
}
}
Hi i am also facing this issue to like I am checking app on MOTO G its not working but on Samsung devices its working So i do Below coding please check:-
Uri selectedImageUri = data.getData();
When we will capture the image from Camera in Android then
Uri
ordata.getdata()
comes null. We have two solutions to resolve this issue.I will implement all methods here, Please carefully watch and read these:-
First I will tell how to get URI from the Bitmap Image: Complete code is:
First we will capture image through Intent that will same for both methods so this code I will write one time only here:
Now we will Implement OnActivityResult :- (This will be same for both above two methods):-
\now we will create all above method to create Uri from Image and Cursor methods via classes:
Now URI path from Bitmap Image
\ Uri from Real path of saved image
This above code works in some mobile but does not work in samsung mobile in my case, so I implemented the common logic for all devices.