我正在发送电子邮件,但当用户从电子邮件作曲家回来时,我需要进行不同的活动,如何实现这一目标?
这是我的代码, //发送邮件
String prestartTypeString = prestartType;
String to = "juanman234@gmail.com";
String subject = "Pre-Start - "+prestartTypeString;
String message = fullName+" has sent you a Pre-Start checklist for equipment "
+registrationNumber+".\n" + "Please find PDF report attached.
\n\nNeed help viewing this report\nEmail us anytime at\nhello@tiks.com.au";
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
//attachment
Uri uri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(),
"generato.pdf"));
email.putExtra(Intent.EXTRA_STREAM, uri);
//need this to prompts email client only
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
setResult(RESULT_OK, email);
我已经检查了
startActivityForResult();
但是不清楚这是否是这样做的方法,并且没有让它起作用
那么当用户从电子邮件意图回来时如何触发功能?
感谢
答案 0 :(得分:1)
使用startActivityForResult()启动活动;并覆盖以下方法
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
//place your code here what you want to do when result is returned, in your case go to different activity
}
当被调用的活动返回结果
时,将调用此方法