[英]startActivityForResult();
Intent emailSend = new Intent(android.content.Intent.ACTION_SEND);
emailSend.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{"tonikg90@gmail.com"});
emailSend.putExtra(android.content.Intent.EXTRA_SUBJECT, "Item Best Seller");
emailSend.putExtra(android.content.Intent.EXTRA_TEXT, map1.toString());
emailSend.setType("text/plain");
//startActivity(Intent.createChooser(emailSend, "Send Email..."));
setResult(RESULT_OK, emailSend);
finish();
break;
after click sending Email Button, It's supposed to go to email service. 点击发送电子邮件按钮后,它应该转到电子邮件服务。 But It immediately goes back to the first activity. 但它立即回到第一个活动。 How can I make it to mail service, and after click "send" then it returns back to the first activity, also with Toast says that "Email has been sent" 如何将其发送到邮件服务,点击“发送”后,它返回到第一个活动,同时Toast说“已发送电子邮件”
First, remove comment from startActivityForResult
method. 首先,从startActivityForResult
方法中删除注释。 Remember: start activity works asynchronously, so just after you used startActivityForResult, setResult
and finish
will be executed. 请记住:start活动是异步工作的,因此在使用startActivityForResult之后,将执行setResult
和finish
。
What you need to do then is to implement the onActivityResult
method, and move setResult
and finish
to there. 那么你需要做的是实现onActivityResult
方法,并移动setResult
并finish
到那里。 onActivityResult
will be called when the email has been sent, thus it will get you back to your main activity. 发送电子邮件时将调用onActivityResult
,因此它将返回到您的主要活动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.