如何直接打开Gmail邮箱作曲家的Android? [英] how to direct open Gmail mail composer in android?
本文介绍了如何直接打开Gmail邮箱作曲家的Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面的code。问题是,当我运行的设备本code。它打开一个Dailogbox的长谷3选择发送邮件。 POP,电子邮件时,Gmail等。 通过点击贾米勒作曲家出现。 我只想而是表示选择的选项dailog框直接显示贾米勒邮件撰写。。请帮我。
意图emailIntent =新的意图(Intent.ACTION_SEND);
emailIntent.setType(text / html的);
字符串主题=我的主题;
emailIntent.putExtra(Intent.EXTRA_SUBJECT,学科);
emailIntent.setType(text / html的);
字符串标题=< p ALIGN =中心>中+ storyTitle +< BR />中+ storyPubDate +&所述; / P>中;
字符串数据=< P>发自ABC APP从我的Android&LT发送; / P>中;
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,Html.fromHtml(标题+数据));
startActivity(Intent.createChooser(emailIntent,电子邮件:));
解决方案
试试这个,完美
公共无效shareToGMail(字符串[]的电子邮件,主题字符串,字符串的内容){
意图emailIntent =新的意图(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL,电子邮件);
emailIntent.putExtra(Intent.EXTRA_SUBJECT,学科);
emailIntent.setType(text / plain的);
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,内容);
最终PackageManager下午= activity.getPackageManager();
最后的名单,其中,ResolveInfo>火柴= pm.queryIntentActivities(emailIntent,0);
ResolveInfo最好= NULL;
对于(最终ResolveInfo信息:匹配)
如果(info.activityInfo.packageName.endsWith(克)|| info.activityInfo.name.toLowerCase()。包括(Gmail的))
最好=信息;
如果(最好的!= NULL)
emailIntent.setClassName(best.activityInfo.packageName,best.activityInfo.name);
activity.startActivity(emailIntent);
}
I am using the following code. Problem it that when I run this code on device. It open a Dailogbox that hase 3 options for sending a mail. "POP , email , gmail" etc. By clicking the gamil the composer appear. I just want to show Gamil mail composer directly. Instead of showing a dailog box for choosing the options. Please help me.
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.setType("text/html");
String subject = "My Subject";
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.setType("text/html");
String title = "<p align='center'>" + storyTitle + "<br/>" + storyPubDate + "</p>";
String data = "<p> Sent From ABC APP Sent from my Android </p>";
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(title + data));
startActivity(Intent.createChooser(emailIntent, "Email:"));
解决方案
Try this one, Perfect
public void shareToGMail(String[] email, String subject, String content) {
Intent emailIntent = new Intent(Intent.ACTION_SEND);
emailIntent.putExtra(Intent.EXTRA_EMAIL, email);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
emailIntent.setType("text/plain");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, content);
final PackageManager pm = activity.getPackageManager();
final List<ResolveInfo> matches = pm.queryIntentActivities(emailIntent, 0);
ResolveInfo best = null;
for(final ResolveInfo info : matches)
if (info.activityInfo.packageName.endsWith(".gm") || info.activityInfo.name.toLowerCase().contains("gmail"))
best = info;
if (best != null)
emailIntent.setClassName(best.activityInfo.packageName, best.activityInfo.name);
activity.startActivity(emailIntent);
}
这篇关于如何直接打开Gmail邮箱作曲家的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文