简体   繁体   English

Android中Gmail的操作意图?

[英]Action Intent for Gmail in android?

I am creating an app in which user can share "something" by clicking on a share button. 我正在创建一个应用程序,用户可以在其中单击共享按钮来共享“某物”。 The steps to share "something" are: 共享“某物”的步骤是:

  1. On clicking the share button the contact list should open 单击共享按钮后,联系人列表应打开
  2. By selecting a contact (with valid a email address) the data should be sent directly to the selected contact from the sender's default email address(Gmail) without popping up a window for selecting an email client like "Gmail", "Dropbox" etc.. 通过选择一个联系人(具有有效的电子邮件地址),数据应从发送者的默认电子邮件地址(Gmail)直接发送到所选联系人,而无需弹出用于选择电子邮件客户端(例如“ Gmail”,“ Dropbox”等)的窗口。 。

I managed to get the email id of contact with the help of http://mobile.tutsplus.com/tutorials/android/android-essentials-using-the-contact-picker/ but after selecting a contact I get a pop up for selecting an email client like "Gmail", "Dropbox" etc.. 我设法在http://mobile.tutsplus.com/tutorials/android/android-essentials-using-the-contact-picker/的帮助下获得了联系人的电子邮件ID,但是在选择了联系人之后,我弹出了选择电子邮件客户端,例如“ Gmail”,“ Dropbox”等。

here is my code so far 到目前为止,这是我的代码

       if( email.length() != 0 )
       {
            Intent sharingIntent = new Intent(
                   android.content.Intent.ACTION_SEND );
            sharingIntent.setType("message/rfc822");
            String shareBody =
                            "Hey buddy listen to this station it is awesome\n"
                            + mNowPlayingSong.mAudioUrl;
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                           "I liked this song" );
           sharingIntent.putExtra(                                                     
                          android.content.Intent.EXTRA_TEXT, shareBody );
           String emailAddressList[] = {email};
           sharingIntent.putExtra(Intent.EXTRA_EMAIL, emailAddressList );
           startActivity( sharingIntent );

You cannot send email silently with the default application. 您不能使用默认应用程序静默发送电子邮件。 You can only create an intent that will call an activity and that will fill in all the fields. 您只能创建将调用活动并填充所有字段的意图。

Other possibility is to embed your own email client into yours application. 其他可能性是将您自己的电子邮件客户端嵌入到您的应用程序中。 In this case, if a user provides credentials then you'll have a possibility to send a email silently. 在这种情况下,如果用户提供了凭据,则您可以静默发送电子邮件。 To implement the second options check this: Sending Email in Android using JavaMail API without using the default/built-in app 要实施第二个选项,请检查以下内容: 使用JavaMail API在Android中发送电子邮件,而无需使用默认/内置应用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM