published: October 11th, 2009
Email via Android Intent code snippet
I’m moving away from using the Android email client in Note To Me, but wanted to share the snippet to launch the client. And who knows, maybe I’ll add it back in if people want it as an option.
Button sendBtn = (Button) findViewById(R.id.send_btn_id);
sendBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
{
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
new String[]{ sendToAddress } );
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject );
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msg );
hideKeyboard();
NoteToMe.this.startActivity(emailIntent);
NoteToMe.this.finish();
}
});
