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