@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == UPLOADIMAGE && resultCode == RESULT_OK)
{
uploadImage.setVisibility(View.GONE);
imageView.setVisibility(View.VISIBLE);
if (data !=null)
{
imageUri=data.getData();
imageView.setImageURI(imageUri);
Uri selectedImage = data.getData();
String[] filePathColumn = { MediaStore.Images.Media.DATA };
Cursor cursor = getContentResolver().query(selectedImage,filePathColumn, null, null, null);
cursor.moveToFirst();
columnIndex = cursor.getColumnIndex(filePathColumn[0]);
attachmentFile = cursor.getString(columnIndex);
Log.e("Attachment Path:", attachmentFile);
URI = Uri.parse("file://" + attachmentFile);
cursor.close();
}
else {Toast.makeText(TutorForm.this,"Uploading image failed",Toast.LENGTH_LONG).show();}
}
super.onActivityResult(requestCode, resultCode, data);
OnClickListner
Intent emailIntent=new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:"+ clientEmail));
emailIntent.putExtra(Intent.EXTRA_TEXT,body);
emailIntent.putExtra(Intent.EXTRA_SUBJECT,"Tutor Registration from App");
emailIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
Uri uri = Uri.parse(imageUri.toString());
emailIntent.putExtra(Intent.EXTRA_STREAM,URI);
startActivity(Intent.createChooser(emailIntent,"Send Via..."));