我使用下面的代码来发送邮件
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();
}
}
}
但每次我发送或丢弃这个消息我收到“邮件取消”举杯。 请帮我把这个问题。
提前致谢。