in my app the user can take an image from the camera intent and then i want to return that image to an image view. How can i do that?
Here is my camera intent:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
startActivityForResult(intent, TAKE_PICTURE);
And onActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
//Check that request code matches ours:
if (requestCode == TAKE_PICTURE)
{
//Check if your application folder exists in the external storage, if not create it:
File imageStorageFolder = new File(Environment.getExternalStorageDirectory()+File.separator+"Kruger National Park");
if (!imageStorageFolder.exists())
{
imageStorageFolder.mkdirs();
Log.d(TAG , "Folder created at: "+imageStorageFolder.toString());
}
//Check if data in not null and extract the Bitmap:
if (data != null)
{
String filename = "image";
String fileNameExtension = ".jpg";
File sdCard = Environment.getExternalStorageDirectory();
String imageStorageFolder1 = File.separator+"Kruger National Park"+File.separator;
File destinationFile = new File(sdCard, imageStorageFolder1 + filename + fileNameExtension);
Log.d(TAG, "the destination for image file is: " + destinationFile );
if (data.getExtras() != null)
{
Bitmap bitmap = (Bitmap)data.getExtras().get("data");
try
{
FileOutputStream out = new FileOutputStream(destinationFile);
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
}
catch (Exception e)
{
Log.e(TAG, "ERROR:" + e.toString());
}
That all works but just want to add it now to my ImageView:
ImageView image = (ImageView) v.findViewById(R.id.imageV);
image.setImageResource();
Could someone please help?