电子邮件意图Android中的结果代码始终为0

时间:2012-12-11 11:38:33

标签: android email android-intent

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();
}

2 个答案:

答案 0 :(得分:0)

始终为0.您无法知道电子邮件是发送/取消还是其他。 :(

答案 1 :(得分:0)

我有同样的问题要做点什么我自己使用AlertDialog和PackageManager列出可用选项并至少在那里捕获取消选择器。