我正在尝试在我的主要活动中开始一项活动。我正在尝试通过电子邮件发送数据。但 当我运行代码我的程序崩溃。这是我开始新活动的代码
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("plain/html");
intent.putExtra(Intent.EXTRA_EMAIL, new String[] {"aaa@gmail.com","ssss@yahoo.com"});
intent.putExtra(Intent.EXTRA_SUBJECT, "subject");
intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("my html text goes here"));
startActivity(intent);
答案 0 :(得分:1)
尝试使用Intent.createChooser方法查找应发送邮件的应用程序,如下所示:
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType(EMAIL_CONTENT_TYPE);
emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] {"aaa@gmail.com","ssss@yahoo.com"});
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
emailIntent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("my html text goes here"));
Intent chooser = Intent.createChooser(emailIntent, "Choose the application to send the email");
startActivity(chooser);