我想在我的 onActivityResult 方法中检测人是否已发送电子邮件或按下后退按钮或丢弃它。我怎么能这样做。
我正在这样做
String[] reciepients = result.toArray(new String[result.size()]);
Intent email = new Intent(android.content.Intent.ACTION_SEND);
email.putExtra(android.content.Intent.EXTRA_EMAIL,reciepients);
email.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
email.putExtra(android.content.Intent.EXTRA_TEXT, emailMessage);
email.setType("text/plain");
email.setType("message/rfc822");
Intent intent = Intent.createChooser(email, "Choose Email Client");
//context.start(Intent.createChooser(email, "Choose Email.."));
((Activity)context).startActivityForResult(intent, FinalVariables.SEND_EMAIL);
onActivityResult
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case FinalVariables.SEND_EMAIL:
if(resultCode==Activity.RESULT_CANCELED){
showToast("Cancelled");
}
else if(resultCode==Activity.RESULT_OK){
showToast("Success");
}
break;
default:
break;
}
}
但是这种方式总是让我取消,因为电子邮件客户端从不将 RESULT 设置为 RESULT_OK。
那么我怎样才能满足我的要求。请建议。
谢谢