有没有什么URI可以指向android里的GMAIL App,帮我上线?
发布于 2010-08-29 03:07:04
我在我的应用程序中使用了这个:
Intent mailClient = new Intent(Intent.ACTION_VIEW);
mailClient.setClassName("com.google.android.gm", "com.google.android.gm.ConversationListActivity");
startActivity(mailClient);发布于 2011-09-18 00:20:25
这只适用于gmail应用程序。
final Intent intent = new Intent(Intent.ACTION_VIEW)
.setType("plain/text")
.setData(Uri.parse("test@gmail.com"))
.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail")
.putExtra(Intent.EXTRA_EMAIL, new String[]{"test@gmail.com"})
.putExtra(Intent.EXTRA_SUBJECT, "test")
.putExtra(Intent.EXTRA_TEXT, "hello. this is a message sent from my demo app :-)");
startActivity(intent);用于大量的电子邮件:
intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "test@gmail.com" });对于单个电子邮件:
intent.setData(Uri.parse("test@gmail.com"));您可以根据需要添加extra putExtra(Intent.EXTRA..)和更改setType。:P
更新(14年1月22日):请务必注意,如果您要使用此代码,请检查以确保用户在其设备上安装了包"com.google.android.gm“。在任何语言中,确保在特定的字符串和初始化中检查null。
请参阅Launch an application from another application on Android

发布于 2014-02-11 19:29:41
不建议使用包名,因为它是一种未记录的方法。如果某一天包名称发生了变化,代码将会失败。
请尝试使用此代码
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
"mailto", "abc@gmail.com", null));
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "This is my subject text");
context.startActivity(Intent.createChooser(emailIntent, null));参考:http://developer.android.com/reference/android/content/Intent.html#ACTION_SENDTO\
https://stackoverflow.com/questions/3470042
复制相似问题