On Wed, Apr 8, 2009 at 5:58 AM, Eileen Novack <[email protected]> wrote:
> I have been following this thread with some interest. Since I also want to
> be able to send an email without any user intervention. Now before anyone
> says that should not be possible since it would be a security problem, let
> me point out that I can send an SMS message without user intervention, if I
> have the permissions set properly. So I would expect that I would also need
> to set permission to allow sending email as well.
There is only one way SMSs can be handled. On the G1 there are two e-mail
clients built in to the system, one of which can have multiple accounts.
You CAN NOT send an e-mail without the user being involved, period, because
you simply have no way to know how that e-mail should be sent.
If you want to send an e-mail, you need to have the code for doing so in
your app, and have the user specify the account information for it.
> I have been poking around a bit in the source code and found this in the
> stock Android email app:
>
> package com.android.email.mail.transport;
>
> /**
> * This class handles all of the protocol-level aspects of sending messages
> via SMTP.
> */
> public class SmtpSender extends Sender {
> public static final int CONNECTION_SECURITY_NONE = 0;
> public static final int CONNECTION_SECURITY_TLS_OPTIONAL = 1;
> public static final int CONNECTION_SECURITY_TLS_REQUIRED = 2;
> public static final int CONNECTION_SECURITY_SSL_REQUIRED = 3;
> public static final int CONNECTION_SECURITY_SSL_OPTIONAL = 4;
> private Transport mTransport; 53 String mUsername; 54 String
> mPassword;
> ..........
>
> /** Allowed formats for the Uri:
> * smtp://user:passw...@server:port CONNECTION_SECURITY_NONE
> * smtp+tls://user:passw...@server:port CONNECTION_SECURITY_TLS_OPTIONAL
> * smtp+tls+://user:passw...@server:port CONNECTION_SECURITY_TLS_REQUIRED
> * smtp+ssl+://user:passw...@server:port CONNECTION_SECURITY_SSL_REQUIRED
> * smtp+ssl://user:passw...@server:port CONNECTION_SECURITY_SSL_OPTIONAL
> *
> * @param uriString the Uri containing information to configure this sender
> */
> public SmtpSender(String uriString) throws MessagingException {
> ...........
>
>
> Which seems to have public methods to send email.
You are looking in the e-mail app. There is nothing public here at all. It
is just internal implementation of the application. It doesn't matter if it
makes a class public in its internal implementation, it is still internal,
and nothing you can use.
> As I understood the
> philosophy behind building Android apps, which is to reuse
> public Intents and methods to allow the scarce available memory to be
> leveraged as much as possible.
Yes, there are intents for using parts of an application that they want to
allow others to access. There is no standard intent for "send an e-mail
without the user being involved," and I don't expect there to be such a
thing any time soon if at all. Some specific e-mail application may define
its own intents to use for that, but this would be specific to that app, so
you would need to know about it yourself. (And if multiple apps were to
support this, you would still need to have the user involved to decide which
app to use, and possible which account in that app to use.)
> So the question is: Can we use the existing code to send email in the stock
> Android email app? Or is that sort of thing frowned upon?
It's not possible.
--
Dianne Hackborn
Android framework engineer
[email protected]
Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails. All such
questions should be posted on public forums, where I and others can see and
answer them.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---