Problems saving a photo to a file
Posted
by Peter vdL
on Stack Overflow
See other posts from Stack Overflow
or by Peter vdL
Published on 2010-04-23T04:54:11Z
Indexed on
2010/04/23
5:03 UTC
Read the original article
Hit count: 380
Man, I am still not able to save a picture when I send an intent asking for a photo to be taken. Here's what I am doing:
Make a URI representing the pathname
android.content.Context c = getApplicationContext();
String fname = c.getFilesDir().getAbsolutePath()+"/parked.jpg";
java.io.File file = new java.io.File( fname );
Uri fileUri = Uri.fromFile(file);
Create the Intent (don't forget the pkg name!) and start the activity
private static int TAKE_PICTURE = 22;
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE );
intent.putExtra("com.droidstogo.boom1." + MediaStore.EXTRA_OUTPUT, fileUri); startActivityForResult( intent, TAKE_PICTURE );
The camera activity starts, and I can take a picture, and approve it. My onActivityResult() then gets called. But my file doesn't get written. The URI is: file:///data/data/com.droidstogo.boom1/files/parked.jpg
I can create thumbnail OK (by not putting the extra into the Intent), and can write that file OK, and later read it back).
Can anyone see what simple mistake I am making? Nothing obvious shows up in the logcat - the camera is clearly taking the picture. Thanks,
Peter
© Stack Overflow or respective owner