I think I have your answer, I searched high and low for this, and it is quite difficult.
First of all, I think on some phones
intent.putExtra(MediaStore.EXTRA_OUTPUT, _imageUri);
ignored: - (
So, my best answer is for you: do not set the "EXTRA_OUTPUT" flag, instead let it start normally and return your new image URI. Then from there use:
Uri u = intent.getData();
To get information about your new image, from there I use FileOutputStream to write the image file to the new location where I want to use it. Then finally I delete the source file. :-)
I know this is something like hokey, but it works, and I think it is pretty reliable .:-)
Hope this helps. :-)
-Jared
8-28-11
@llango J
Well, here, the whole code, you can copy and paste it and see if you can do it :-)
First you need to call the camera as follows:
startActivityForResult(CameraIntent, TAKE_PICTURE);
Then for the result you will need the following:
@Override public void onActivityResult(int requestCode, int resultCode, Intent intent) { if (resultCode == Activity.RESULT_OK) { switch (requestCode) { case TAKE_PICTURE: Uri u = intent.getData();
And then the main magic happens in this function:
private void WriteFiles(Uri myNewPic) { String TempFilePath; String TempPath; File directory = new File("/sdcard/" + getString(R.string.app_name)); if (!directory.exists()) { directory.mkdirs(); } String TempPictureFile; try { TempPictureFile = myNewPic.getLastPathSegment() + ".jpg"; TempFilePath = directory.getPath() + "/" + TempPictureFile; FileOutputStream myOutStream = new FileOutputStream(TempFilePath); InputStream myInStream = getContentResolver().openInputStream(myNewPic); FileIO myFileIO = new FileIO(); myFileIO.copy(myInStream, myOutStream);
I think this is all you need to save money using your own camera app. However, I must warn you that I eventually abandoned this code because I needed more flexibility and reliability than suggested (I think if you use this application on a ton of different phones, I could see that he has problems for one reason or another. Like, for example, I had TON problems as a result of Samsung setting up its user interface, so everything works fine on all phones except Samsung .: -P). So I just created my own application for the camera, but I'm sure that depending on your application, this might work for you. Anyway .... good luck! :-)
Ok, here is my FileIO class that I use, sorry, I did not include this initially:
import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import android.util.Log; public class FileIO { private static final int BUFFER_SIZE = 1024 * 2; public FileIO() {