My app successfully makes email but when I try to attach an image the code crashes here is the code snippet
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL , new String[]{"email address"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT , "body of email");
// i.putExtra(Intent.EXTRA_STREAM, R.drawable.pic4);
try {
startActivity(Intent.createChooser(i, "Send mail..."));
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(EidCards.this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
}
the line which is commented makes the code crash please suggest a way out !
This does not work for you:
i.putExtra(Intent.EXTRA_STREAM, R.drawable.pic4);
What is the type of R.drawable.pic4? Is that not an integer used to resolve the drawable?
See how others are attaching images: Sharing an image with Google+ app using Intent.ACTION_SEND and Intent.EXTRA_STREAM