0

请检查下面提到的代码。我也使用了 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);
4

1 回答 1

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
  }
}
于 2013-08-19T06:03:30.277 回答