发送电子邮件意图Intent intent = new Intent(Intent.ACTION_SEND);intent.setType("text/html");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));上面的代码打开一个对话框,显示以下应用:蓝牙、谷歌文档、雅虎邮件、Gmail、Orkut、Skype等。实际上,我想过滤这些列表选项。我只想显示电子邮件相关的应用,如Gmail,雅虎邮件。怎么做?我在“Android市场”应用程序上看到了这样的例子。开放Android市场应用程序打开开发人员指定其电子邮件地址的任何应用程序。(如果你找不到这样的应用程序,只需打开我的应用程序:-market://details?id=com.becomputer06.vehicle.diary.free,或按“车辆日记”搜索)向下滚动到“Developer”点击“发送电子邮件”对话框只显示电子邮件应用程序,如Gmail、雅虎邮件等。它不显示蓝牙、Orkut等。是什么代码产生这样的对话框?
3 回答
叮当猫咪
TA贡献1776条经验 获得超12个赞
intent.setType("text/plain");
android.content.Intent.ACTION_SENDTO
new Intent(Intent.ACTION_SENDTO);
编辑:message/rfc822
"text/plain"
message/rfc822
.mhtml, .mht, .mime
长风秋雁
TA贡献1757条经验 获得超7个赞
String email = /* Your email address here */String subject = /* Your subject here */String body = /* Your body here */String chooserTitle = /* Your chooser title here */
Uri
:
Uri uri = Uri.parse("mailto:" + email) .buildUpon() .appendQueryParameter("subject", subject) .appendQueryParameter("body", body) .build();Intent emailIntent = new Intent(Intent.ACTION_SENDTO, uri);startActivity(Intent.createChooser(emailIntent, chooserTitle));
Intent
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + email));emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); emailIntent.putExtra(Intent.EXTRA_TEXT, body);//emailIntent.putExtra(Intent.EXTRA_HTML_TEXT, body); //If you are using HTML in your body textstartActivity(Intent.createChooser(emailIntent, "Chooser Title"));
ShareCompat
:
Activity activity = /* Your activity here */ShareCompat.IntentBuilder.from(activity) .setType("message/rfc822") .addEmailTo(email) .setSubject(subject) .setText(body) //.setHtmlText(body) //If you are using HTML in your body text .setChooserTitle(chooserTitle) .startChooser();
- 3 回答
- 0 关注
- 928 浏览
添加回答
举报
0/150
提交
取消