小编Pau*_*aul的帖子

Android Studio mailto Intent 不显示主题和邮件正文

我正在尝试从我的 Android 应用程序发送电子邮件。单击一个按钮,gmail 应该会打开并显示一封包含我之前定义的收件人、主题和电子邮件正文的新电子邮件。到目前为止,我已经尝试发送 Intent.ACTION_VIEW 和 Intent.ACTION_SENDTO。两者都只向收件人显示我的草稿。主题和信息都受到压制。奇怪的是当使用模拟器时,它工作得很好。还试图锁定android错误日志。好像没有权限 这真的是权限问题还是其他原因?我真的很感激任何帮助

这是我的代码:

  • 通过 ACTION_VIEW 发送电子邮件
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mailto:" + to));
intent.putExtra(intent.EXTRA_SUBJECT, subject);
intent.putExtra(intent.EXTRA_TEXT, message);
mainActivity.startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
  • 通过 ACTION_SENDTO 发送电子邮件
Intent email = new Intent(Intent.ACTION_SENDTO);
email.setType("message/rfc822");
email.putExtra(Intent.EXTRA_EMAIL, new String[]{to});
email.putExtra(Intent.EXTRA_SUBJECT, subject);
email.putExtra(Intent.EXTRA_TEXT, message);
mainActivity.startActivity(Intent.createChooser(email, "Choose an Email client :"));
Run Code Online (Sandbox Code Playgroud)
  • 来自 logcat 的错误消息
2019-12-13 01:30:35.172 29268-29268/? E//system/bin/webview_zygote32: failed to make and chown /acct/uid_99044: Permission denied
2019-12-13 01:30:35.172 29268-29268/? E/Zygote: createProcessGroup(99044, 0) failed: Permission denied
2019-12-13 01:30:35.206 29289-29289/? E/asset: setgid: Operation not permitted
2019-12-13 …
Run Code Online (Sandbox Code Playgroud)

java email error-handling android android-intent

19
推荐指数
4
解决办法
6843
查看次数

标签 统计

android ×1

android-intent ×1

email ×1

error-handling ×1

java ×1