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();
}
答案 0 :(得分:0)
始终为0.您无法知道电子邮件是发送/取消还是其他。 :(
答案 1 :(得分:0)
我有同样的问题要做点什么我自己使用AlertDialog和PackageManager列出可用选项并至少在那里捕获取消选择器。