好的,所以我想看看是否可以完成。因此,我有一个基本表格提交给我的应用程序。用户可以填写一些信息,例如支持请求。这包括几个编辑文本和查看文本。然后,它的文本构建器代码中有一个小文本代码,以将文本合并在一起,并意图通过电子邮件将其与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 += "nnEmail:n" + emailtext.getText().toString();
message += "nnContact#:n" + phonetext.getText().toString();
message += "nnTopic:n" + topictext.getText().toString();
message += "nnDescription:n" + detailstext.getText().toString();
message += "nn" + 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");
您需要使用android.net.uri
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///sdcard/mysong.mp3"));
将文件连接到电子邮件。