How to attach image view as an email attachment?
android, email-attachments, imageview
Solution
Call `getDrawingCache()` on your image view. This returns the cache bitmap of the view. Read documentation here.
Save the bitmap as PNG, create a mail and attach and send.
Bitmap bmp = imgView.getDrawingCache();
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_WORLD_READABLE);
bmp.compress(Bitmap.CompressFormat.PNG, 0, fos);
fos.close();
/* Create a Action_SEND intent and attach the FILENAME image to the mail. */
...
intent.putExtra(Intent.EXTRA_STREAM, FILENAME); // FILENAME is URI
...
startActivity(....);
Problem
I am generating pie chart on image view, I want to send it via email. How to convert image view's image to email attachment, as its not available in resources?