如何在发送邮件后再次移动MainActivity? [英] How to move again MainActivity after sending the mail?

查看:150
本文介绍了如何在发送邮件后再次移动MainActivity?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发一个应用程序,其中我意图的帮助下发送电子邮件。我成功地从MainActivity发送邮件,但问题是,因为我的发送按钮,点击发送电子邮件,我要在应用程序之外。但是在发送电子邮件后,我想在MainActivity再来。这里是我的code。

 保护无效sendEmail(){
    的String [] TO = {xxx@gmail.com};
    意图emailIntent =新意图(Intent.ACTION_SEND);
     emailIntent.setData(Uri.parse(电子邮件地址:));
      emailIntent.setType(text / plain的);      emailIntent.putExtra(Intent.EXTRA_EMAIL,TO);
      emailIntent.putExtra(Intent.EXTRA_SUBJECT,YYYY);
      emailIntent.putExtra(Intent.EXTRA_TEXTZZZZ);      尝试{
             startActivity(Intent.createChooser(emailIntent,发送邮件...));
             完();
          }赶上(android.content.ActivityNotFoundException前){
             Toast.makeText(MainActivity.this,
             没有安装电子邮件客户端。Toast.LENGTH_SHORT).show();
          }}


解决方案

您可以删除完成()或者使用 startActivityForResult

I am developing one app, in which I am sending the email with the help of intent. I am successfully sending the mail from MainActivity, but problem is that, as I am clicking on send button for sending the email, I am going to outside of the app. But after sending the email I want to come again on MainActivity. Here is my code.

 protected void sendEmail() {
    String[] TO = {"xxx@gmail.com"};
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
     emailIntent.setData(Uri.parse("mailto:"));
      emailIntent.setType("text/plain");

      emailIntent.putExtra(Intent.EXTRA_EMAIL, TO);
      emailIntent.putExtra(Intent.EXTRA_SUBJECT, "yyyy");
      emailIntent.putExtra(Intent.EXTRA_TEXT, "zzzz.");

      try {
             startActivity(Intent.createChooser(emailIntent, "Send mail..."));
             finish();
          } catch (android.content.ActivityNotFoundException ex) {
             Toast.makeText(MainActivity.this, 
             "There is no email client installed.", Toast.LENGTH_SHORT).show();
          }

}

解决方案

You can remove finish() Or using startActivityForResult

这篇关于如何在发送邮件后再次移动MainActivity?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆