2011-04-08 102 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")); 
相關問題