Very much not pretty, but this is how I'm doing it. Note that due to a bug, the file saved is 1/16 the full resolution (1/4 in each dimension).
String SD_CARD_TEMP_DIR = Environment.getExternalStorageDirectory() + File.separator + "tmpPhoto.jpg";
Intent takePictureFromCameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
takePictureFromCameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(new
File(SD_CARD_TEMP_DIR)));
startActivityForResult(takePictureFromCameraIntent, TAKE_PICTURE_WITH_CAMERA);
.
.
.
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Picture taken from camera
if (requestCode == TAKE_PICTURE_WITH_CAMERA) {
if (resultCode == Activity.RESULT_OK) {
// http://code.google.com/p/android/issues/detail?id=1480
//Toast.makeText(AddPhotos.this, "" + data, Toast.LENGTH_SHORT).show();
// on activity return
File f = new File(SD_CARD_TEMP_DIR);
try {
Uri capturedImage =
Uri.parse(android.provider.MediaStore.Images.Media.insertImage(getContentResolver(),
f.getAbsolutePath(), null, null));
Log.i("camera", "Selected image: " + capturedImage.toString());
f.delete();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else {
Log.i("Camera", "Result code was " + resultCode);
}
}
}