我想直接打开android默认电子邮件客户端。除了“三星Galaxy S”之外,它在大多数设备中都有效。实际上问题是我在编码中设置了电子邮件的主题和正文,这在大多数设备中都有效,但它并没有在三星Galaxy中实现。这里打开了一个空的撰写邮件。我该怎么做才能让它发挥作用?
代码
btn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("text/html");
List<ResolveInfo> resInfo = getPackageManager().queryIntentActivities(emailIntent, 0);
if (!resInfo.isEmpty())
{
for (ResolveInfo info : resInfo)
{
System.out.println("info.activityInfo.packageName:"+info.activityInfo.packageName.toLowerCase());
System.out.println("info.activityInfo.name:"+info.activityInfo.name.toLowerCase());
if (info.activityInfo.packageName.toLowerCase().contains("mail") || info.activityInfo.name.toLowerCase().contains("mail"))
{
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "My Allergy Journal");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "My Allergy Journal Body");
emailIntent.setPackage(info.activityInfo.packageName);
startActivity(Intent.createChooser(emailIntent, "Email:"));
}
}
}
}});
答案 0 :(得分:0)
试试这段代码
Intent email=new Intent(Intent.ACTION_SEND);
email.putExtra(Intent.EXTRA_SUBJECT, "YOUR SUBJECT");
email.putExtra(Intent.EXTRA_TEXT,"YOUR MESSAGE BODY");
email.setType("message/rfc822");
a.startActivity(Intent.createChooser(email, "Choose an Email Client :"));