Android Send email Log
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_send_mail) {
sendEmail();
return true;
}
return super.onOptionsItemSelected(item);
}
private void sendEmail() {
CourseInfo course = (CourseInfo) mSpinnerCourses.getSelectedItem();
String subject = mTextNoteTitle.getText().toString();
String text = "Checkout what I learned in the Pluralsight crouse \"" +
course.getTitle() + " \"\n" + mTextNoteText.getText();
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc2822");
intent.putExtra(Intent.EXTRA_SUBJECT,subject );
intent.putExtra(Intent.EXTRA_TEXT,text );
startActivity(intent);
}
using Intent
留言
張貼留言