2011-04-08 103 views
11

当我点击我的应用程序中的按钮时,是否可以打开Gmail等电子邮件客户端?Android以编程方式打开电子邮件客户端

+1

的可能重复[如何打开Gmail撰写时被点击Android应用程序的按钮?](http://stackoverflow.com/questions/3935009/how-to-open-gmail-compose-when-a-button-is-in-android-app) – 2011-04-08 15:13:57

回答

24

是的。你可以通过Intents启动它。

Intent i = new Intent(Intent.ACTION_SEND); 
i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ emailAddress }); 
i.putExtra(android.content.Intent.EXTRA_SUBJECT, subject); 
i.putExtra(android.content.Intent.EXTRA_TEXT, text); 
startActivity(Intent.createChooser(i, "Send email")); 
+1

确实是工作伙伴。这是我做的方式Intent i = new Intent(Intent.ACTION_SENDTO,Uri.fromParts( “mailto”,EMAIL_ADDRESS,null)); – jonney 2015-07-09 09:06:52

3
Intent i = new Intent(Intent.ACTION_SENDTO, Uri.fromParts(
        "mailto", EMAIL_ADDRESS, null)); 

多达做的最新方式,

 i.putExtra(android.content.Intent.EXTRA_SUBJECT, SUBJECT); 
     i.putExtra(android.content.Intent.EXTRA_TEXT, BODY); 
     startActivity(Intent.createChooser(i, "Send email")); 
相关问题