好的,所以我想看看是否可以完成。所以我有一个基本的申请表提交。用户可以在其中填写一些信息,例如支持请求。这包括几个编辑文本和视图文本。然后它有一个小的文本构建器代码,用于将文本合并在一起并将意图发送到 android 系统以通过电子邮件输出。
所以我想知道的是如何将图像添加到这个因素中。
public void onClick(View v) {
String[] recipients = new String[]{"email@email.com", "email@email.com",};
String subject = textSubject.getText().toString();
String message = "Name:\n" + nametext.getText().toString();
message += "\n\nEmail:\n" + emailtext.getText().toString();
message += "\n\nContact#:\n" + phonetext.getText().toString();
message += "\n\nTopic:\n" + topictext.getText().toString();
message += "\n\nDescription:\n" + detailstext.getText().toString();
message += "\n\n" + sentby.toString();
Intent email = new Intent(Intent.ACTION_SEND);
email.putExtra(android.content.Intent.EXTRA_EMAIL, recipients);
//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");
//plain text
email.setType("text/plain");
startActivity(Intent.createChooser(email, "Choose an Email client :"));
finish();
}
});
因此,这里是字符串构建器代码的示例代码,用于合并在 xml 布局文件的编辑文本表单中键入的内容。
现在我想知道该怎么做,我需要什么代码在我的 xml 布局上添加一个插入图像按钮,从用户的文件管理器或画廊应用程序中选择图像的代码,然后我如何将它添加到通过电子邮件发送的总体意图。
任何建议、反馈、源代码示例和任何帮助都会有所帮助。提前致谢。
更新
我找到了下面的代码,想知道是否有人使用过它,以及它是否可以在我上面的代码中工作。
sendIntent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");