I am developing an app, where an image taken from the native camera app. is to be shown to the user. The code I did is:
/* Intent */
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);
/* Result */
onActivityResult(int requestCode, int resultCode,
Intent returnIntent) {
if(requestCode == TAKE_PICTURE) {
//picture from Camera
if (resultCode == Activity.RESULT_OK) {
if(returnIntent != null) {
try {
// Get the file path where the image is stored.
// This runs fine on all devices, except Samsung ones.
Uri selectedImage = returnIntent.getData();
if(selectedImage == null) {
if(returnIntent.getExtras() != null &&
returnIntent.getExtras().get(AppConstants.DATA) != null) {
// But, I get the image Bitmap here. Means the image is stored in disk.
Bitmap bmp = (Bitmap) returnIntent.getExtras().get(AppConstants.DATA);
}
}
} catch (Exception e) {
//
}
}
}
}
}
The problem here is, the above code works fine on all devices I tried (HTC's, SE's) but it somehow fails in the Samsung ones. The "Uri selectedImage = returnIntent.getData();" never returns anything. As my entire app is built over this logic of file path storing, I am not able to proceed. Is there any solution people.
See Specify filename for picture to be taken for code to specify an EXTRA_OUTPUT parameter for the Intent which lets you specify a filename for the picture. Remember the filename when the activity result is called and use that if the intent.getData is NULL
And if you read the other comments in that bug report, you'll realize how many problems that picture taking on Android has.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With