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