在android中获取电子邮件发送或取消的状态

时间:2013-07-24 13:37:45

标签: android android-activity

请检查下面提到的代码。 我也使用Java邮件api,但是使用了用户名和密码。 有没有其他方法来获取电子邮件发送或取消的状态。 请告诉我在Android中处理电子邮件发送或取消状态的过程。

Intent emailActivity = new Intent(Intent.ACTION_SEND);

// set up the recipient address
emailActivity.putExtra(Intent.EXTRA_EMAIL, new String[] { to });

// set up the email subject
emailActivity.putExtra(Intent.EXTRA_SUBJECT, subject);

// you can specify cc addresses as well
// email.putExtra(Intent.EXTRA_CC, new String[]{ ...});
// email.putExtra(Intent.EXTRA_BCC, new String[]{ ... });

// set up the message body
emailActivity.putExtra(Intent.EXTRA_TEXT, message);

emailActivity.setType("message/rfc822");

startActivityForResult(Intent.createChooser(emailActivity,
                    "Select your Email Provider :"), 1000);

1 个答案:

答案 0 :(得分:0)

使用startActivityForResult启动发送电子邮件的活动应覆盖onActivityResult

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);

  // Check requestCode to know which request result you got back
  switch (requestCode) {
  case YOUR_REQUEST_ID:
    // Check the resultCode
    if(resultCode == RESULT_OK) {
      // The activity reported that everything went ok
    }
    break;
  // Check other results here
  }
}