Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
String[] recipients = new String[]{"test@sample.com"};
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, recipients); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Sending ALL" );
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hi This is the Mail");
emailIntent.setType("text/plain");
emailIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(Intent.createChooser(emailIntent, "Send mail..."),1);
我有上面的电子邮件意图,它工作正常,我想在发送/丢弃消息后得到结果代码。所以我尝试了onActivityResult()
函数,但resultCode
总是 0。对不起英语,请帮我解决这个问题。
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Toast.makeText(getApplicationContext(),"Result value is" + String.valueOf(resultCode), Toast.LENGTH_SHORT).show();
}