I’m writing an application which have to take a picture and send it to a web service.
There is the code I use to :
i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
outputFileUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory()+"/appicture.jpg"));
Log.i("URI", outputFileUri.toString());
i.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(i, cameraData);
The URI looks like :
file:///sdcard/appicture.jpg
But if I put “outputFileUri” var in the i.putExtra, my app just quit.
If not, I can take the picture but I can’t get her URI then unable to send it to my webservice.
EDIT 1 :
Error log ( on the activity resylt)
06-26 09:17:46.108: I/Cam error(699): java.lang.NullPointerException
EDIT 2 :
If I remove the “outputFileUri”, I correctly got the Image. But, then I’m unable to convert the Bitmap into File to be able to send it.
if(resultCode == RESULT_OK){
Bundle extras = data.getExtras();
_bmp = (Bitmap) extras.get("data");
}
EDIT 3 :
The problem was from
_bmp = (Bitmap) extras.get(“data”);
And the picture is correctly save in the sd card.
Add WRITE_EXTERNAL_STORAGE permission in Manifest:
EDIT:
if you are passing Image Uri in Intent for Capturing image then get image as in
onActiityResultas:and if you want to get image as data in
onActiityResultthen Launch Camra as:in onActivityResult: