我正在使用以下代码发送邮件
Intent i = new Intent(Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(Intent.EXTRA_EMAIL, new String[] { "abc@yahoo.com" });
i.putExtra(Intent.EXTRA_CC, new String[] { bcc_string });
i.putExtra(Intent.EXTRA_SUBJECT, "Video Suggest");
i.putExtra(Intent.EXTRA_TEXT, url_link);
try {
startActivityForResult(Intent.createChooser(i, "Send Mail..."), 1);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(AllVideos.this, "There are no email clients installed.", Toast.LENGTH_SHORT)
.show();
}
在我的活动结果中,我使用以下代码
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// System.out.println("inactivity");
// Toast.makeText(AllVideos.this, "Mail Send", 10).show();
System.out.println("inside activity result");
if (requestCode == 1) {
if (requestCode == 1 && resultCode == RESULT_OK) {
Toast.makeText(this, "Mail sent.", Toast.LENGTH_SHORT).show();
} else if (requestCode == 1 && resultCode == RESULT_CANCELED) {
Toast.makeText(this, "Mail canceled.", Toast.LENGTH_SHORT)
.show();
} else {
Toast.makeText(this, "Plz try again.", Toast.LENGTH_SHORT)
.show();
}
}
}
但是每次我发送或丢弃消息时,我都会收到“邮件已取消”的祝酒词。请帮我解决这个问题。
提前致谢。