Hi guys,

I am having a problem capturing an image from the built-in camera app
on the Samsung Galaxy S.  (I also posted this on StackOverflow)

I have a button on my app that when pressed launches the camera:
//-------------------------------------------------------------
ContentValues values = new ContentValues();
values.put(Images.Media.MIME_TYPE, "image/jpeg");

mPicUri = getContentResolver().insert(Media.EXTERNAL_CONTENT_URI,
values);

intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mPicUri.getPath());
startActivityForResult(intent, REQ_CODE_TAKE_PIC);
//-------------------------------------------------------------

>From what I read on the interwebz, I can get the full-sized just-taken
picture using the URI I passed to the intent. And so I have this on my
onActivityResult:
//-------------------------------------------------------------
Uri selectedImage = mPicUri;
String[] filePathColumn = {MediaStore.Images.Media.DATA};

Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
cursor.moveToFirst();

int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
//-------------------------------------------------------------

And then using the variable filePath, I set the image in an ImageView.
I am getting no image, and when I stepped through the code, I found
out that BitmapFactory.decodeFile() is returning null.

Bitmap chosenPic = BitmapFactory.decodeFile(filePath);


So I tried a little more debugging. I found out that mPicUri returns a
seemingly valid URI, such as: content://media/external/images/media/90.
After the picture is taken and the user chooses to save the picture,
the cursor resolves to the following filePath: /sdcard/DCIM/Camera/
1285601413961.jpg. No bitmap is decoded though, BUT when I looked
through the gallery, the picture I just took is there. So I tried to
take a look at the URI of that picture, and this is what I got:

URI is:           content://media/external/images/media/91
File path is:     /sdcard/DCIM/Camera/2010-09-27 23.30.30.jpg

And so, it looks like the value I got from mPicUri is not the final
URI that will be used.

Am I missing a step here? All I really want to do is retrieve the file
of the just-taken picture.

Thanks in advance,
Zarah.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to