Here are two methods using intents.
Method one, you want to let the user choose the email client:
Button sendBtn = (Button) findViewById(R.id.send_btn_id);
sendBtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
Intent i = new Intent(Intent.ACTION_SEND);
//i.setType("text/plain"); //use this line for testing in the emulator
i.setType("message/rfc822") ; // use from live device
i.putExtra(Intent.EXTRA_EMAIL, new String[]{"test@gmail.com"});
i.putExtra(Intent.EXTRA_SUBJECT,"subject goes here");
i.putExtra(Intent.EXTRA_TEXT,"body goes here");
startActivity(Intent.createChooser(i, "Select email application."));
}
});
and method two, you want to specify a client (NoteToMe here), replace the intent request by:
NoteToMe.this.startActivity(emailIntent);
NoteToMe.this.finish();
0 comments: