在Android中发送电子邮件,无需用户交互 [英] Send e-mail in Android without user interacton

查看:258
本文介绍了在Android中发送电子邮件,无需用户交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用用户已经设置的任何默认邮件提供者在我的应用程序中发送电子邮件。必须可以发送电子邮件而不需要任何用户交互。如果我可以避免显示任何UI,那将是最好的解决方案。不能接受的一件事是硬编码或请求用户输入他们的电子邮件凭证。用户必须已经使用其凭据设置了Gmail等帐户。我所有的应用程序都是使用已经安装的现有电子邮件提供商。

I would like to send an e-mail in my app using whatever default mail provider the user already has setup. It must be possible to send the e-mail without requiring any user interaction. If I can avoid showing any UI, that would be the best solution. The one thing that is unacceptable is to either hardcode or request the user enter their e-mail credentials. The user had to have already setup their account such as Gmail with their credentials. All my app does is use an existing e-mail provider that has been setup.

我在这里发现的大多数帖子都是使用意图,但是从我所理解的那个将显示电子邮件用户界面,并要求用户按发送按钮。

Most of the posts I have found here use an Intent but from what I understand, that will show the e-mail UI and requires the user to press the Send button.

推荐答案

在进一步挖掘之后,我认为有一个解决方案。 Google现在已经使用OAuth 2.0添加了对Gmail身份验证的支持,避免了访问用户的用户名和密码。由于我的应用程式要求用户拥有Gmail帐户,因此可能是解决方案。当然,对于不支持OAuth的任何其他电子邮件提供商来说,这并不适用,但由于Google关心保护用户名/密码,所以这种做法似乎是正确的。需要研究如何在我的应用程序中使用OAuth,但理论上应该是可能的。一旦用户授予Google服务的权限,该应用程序将收到一个令牌,该令牌将持续使用该权限。尚未解决的问题是Gmail是否支持使用OAuth发送电子邮件:

After some more digging around, I think there is a solution. Google has now added support for Gmail authentication using OAuth 2.0 which avoids the need to access the user's username and password. Since my app will require the user to have a Gmail account, this might be the solution. Of course this won't work for any other e-mail provider that doesn't support OAuth but since Google is concerned about protecting username/passwords, this approach seems to be right. Need to look into how to use OAuth from within my app, but theoretically it should be possible. Once a user grants permission to a Google service, the app receives a token that is used for the lifetime that the permission remains. The question that is still unresolved is whether Gmail supports sending an e-mail using OAuth:

Google带来OAuth 2.0支持Gmail和Google Talk,使第三方应用程序更安全

OAuth2 Gmail支持

Google的示例代码Gmail支持和OAuth2

Android应用程序演示如何使用OAuth发送电子邮件

YouTube视频显示移动应用程序如何使用2步验证在应用程序中

使用OAuth 2.0的Android文档

使用OAuth2发送电子邮件的代码示例

这篇关于在Android中发送电子邮件,无需用户交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆