It is very simple to save BITMAP into image
if (BITMAP != null) {
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
BITMAP.compress(Bitmap.CompressFormat.PNG, 40,
bytes);
// you can create a new file name ".jpg" in
// sdcard folder.
String pngUri = Environment
.getExternalStorageDirectory()
+ File.separator
+ _KNAME
+ "_"
+ General_Class.selectitem_
+ "_"
+ _BVALUE
+ "_View.jpg";
newFile = new File(pngUri);
newFile.createNewFile();
// write the bytes in file
FileOutputStream fo = new FileOutputStream(newFile);
fo.write(bytes.toByteArray());
// remember close de FileOutput
fo.close();
} catch (Exception e) {
Log.d("error in save image", "-->"
+ e.getMessage().toString());
}
}
Use that image path in share intent.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
// set the type
shareIntent.setType("text/plain");
// add a subject
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
"Email with attachmetn");
// build the body of the message to be shared
String shareMessage = "\n";
// add the message
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,
shareMessage);
shareIntent.putExtra(android.content.Intent.EXTRA_STREAM,
Uri.fromFile(newFile));
// start the chooser for sharing
startActivity(Intent.createChooser(shareIntent,
"Please select sharing medium"));
enjoy coding...