I'm trying to retrieve a file from my ACTION_IMAGE_CAPTURE activity, but when I use
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
I get a null intent on my activity result. Here is the full code.
The intent
Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
startActivityForResult(cameraIntent, 1888);
My onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == 1888 && resultCode == RESULT_OK)
{
Uri uri = (Uri)data.getData();
Intent i = new Intent(getApplicationContext(), Camara.class);
i.putExtra("uri", uri);
startActivity(i);
}
}
i'm using the following permissions
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
i need to access to the file of the image captured but i'm getting null on my parameter data
and then, How do I get the file? Like this?
File myfile = new File(uri.getPath());
I also tried this:
Uri uri = (Uri)data.getData();
Intent i = new Intent(getApplicationContext(), Camara.class);
i.putExtra("uri", uri);
startActivity(i);
In this case I can get the bitmap with this
Bitmap lafoto = MediaStore.Images.Media.getBitmap(this.getContentResolver(), uri);
but i can't get the File
I tried to follow this solution but didn't work for me Get Path of image from ACTION_IMAGE_CAPTURE Intent