如何控制从电子邮件应用程序到呼叫 activity
How to get control from email app to calling activity
我有一个场景,我需要从我的 android 应用程序发送电子邮件。
String to = textTo.getText().toString();
String subject = textSubject.getText().toString();
String message = textMessage.getText().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
//email.putExtra(Intent.EXTRA_CC, new String[]{ to});
//email.putExtra(Intent.EXTRA_BCC, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
//need this to prompts email client only
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
我使用上面的代码打开了 gmail 应用程序并发送了邮件。
但是有没有一种方法可以从我们的应用程序中跟踪,比如通过调用 activity 或片段来跟踪邮件是否已发送,以便我需要在我的代码中进行一些 UI 更新
你不能,这不是 API 的一部分。它returns一旦你按下发送按钮即使没有发送。
由于 Intent 启动了另一个应用程序,所以在这些其他应用程序中,有责任 return 某种信息,无论邮件是否已发送 - 我不知道有任何 Mail 应用程序真正做到了这一点。即使有,也不是每个人都会用。
因此,确保您获得信息的唯一方法是使用您自己的邮件服务器和 AndroidMail。这样您就可以直接从您的应用程序发送邮件,而不是像使用 Intent.ACTION_SEND
那样将任务分配给其他应用程序
我有一个场景,我需要从我的 android 应用程序发送电子邮件。
String to = textTo.getText().toString();
String subject = textSubject.getText().toString();
String message = textMessage.getText().toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_EMAIL, new String[]{ to});
//email.putExtra(Intent.EXTRA_CC, new String[]{ to});
//email.putExtra(Intent.EXTRA_BCC, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
//need this to prompts email client only
email.setType("message/rfc822");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
我使用上面的代码打开了 gmail 应用程序并发送了邮件。
但是有没有一种方法可以从我们的应用程序中跟踪,比如通过调用 activity 或片段来跟踪邮件是否已发送,以便我需要在我的代码中进行一些 UI 更新
你不能,这不是 API 的一部分。它returns一旦你按下发送按钮即使没有发送。
由于 Intent 启动了另一个应用程序,所以在这些其他应用程序中,有责任 return 某种信息,无论邮件是否已发送 - 我不知道有任何 Mail 应用程序真正做到了这一点。即使有,也不是每个人都会用。
因此,确保您获得信息的唯一方法是使用您自己的邮件服务器和 AndroidMail。这样您就可以直接从您的应用程序发送邮件,而不是像使用 Intent.ACTION_SEND