0

I have a image view where it show the image i took from camera

this is how i take the image :

    btnImg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent i = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            startActivityForResult(i, 0);
        }
    });

this is how i give the image to ImageView:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    super.onActivityResult(requestCode, resultCode, data);
    Bitmap bitmap = (Bitmap) data.getExtras().get("data");
    img.setImageBitmap(bitmap);
}

and i want to get the image so that i can attach it in email

1 Answers1

0

In onActivityResult you can receive file path

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
    super.onActivityResult(requestCode, resultCode, data);
    Uri imageURI = data.getData();
    String[] projection = { MediaStore.Images.Media.DATA };
    Cursor cursor = managedQuery(imageURI, projection, null, null, null);
    int column_index = cursor
            .getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    String filePath=cursor.getString(column_index);
}

After getting filepath you can attach to email.

Ramesh sambu
  • 3,577
  • 2
  • 24
  • 39