3

I am trying to send an email from a Google Glass app I am developing. However, it seems my app can not find any application (including Gmail) to perform this action. Normally an Android phone would display several choices for sharing any kind of contents (sms, mail, blutooth), but not in Google Glass. Has anyone face the same issue?

I have tried different codes:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
startActivity(Intent.createChooser(i, "Send mail..."));

This one throws dialog saying No apps can perform this action. The following ones:

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_EMAIL  , new String[]{"recipient@example.com"});
i.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
i.putExtra(Intent.EXTRA_TEXT   , "body of email");
startActivity(i);

Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("message/rfc822");
intent.putExtra(Intent.EXTRA_EMAIL, "recipient@example.com");
intent.setData(Uri.parse("mailto:" + "recipient@example.com"));
intent.putExtra(Intent.EXTRA_SUBJECT, "xxxxxxxxxxxx");
intent.putExtra(Intent.EXTRA_TEXT, "xxxxxxxxxxxxxxxxx");
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

say No activity found to handle intent. I am able to send/receive mails with the Gmail account in the Google Glass timeline, but it looks like my app is not recognizing it or the other way around. Any clue?

I have seen it can be done by implementing my own mail service using JavaMail API, for instance, but I dont want the user to entry passwords and neither the code to contain them.

Thanks in advance.

Andrew
  • 4,953
  • 15
  • 40
  • 58

3 Answers3

3

Without an email intent on Glass you will have to do it in a more raw way, there are instructions in this answer for doing so, including emails with an attached image, note the part about internet permission:

Take a look of this:- Sending Email in Android using JavaMail API without using the default/built-in app

Community
  • 1
  • 1
Laxmeena
  • 780
  • 2
  • 7
  • 28
  • As I just edited, I can not afford asking the user for his password or keeping it in the code. Thanks anyway for your fast response. – Manuel Martinez Jul 11 '14 at 09:44
2

You cannot send an email from Google Glass

"Email

You can’t initiate an email at this moment, but rather you can only reply to one. If you click an email on your timeline you will have the option to read more, reply, archive, star, or delete an email. You reply to an email the same way you would with a message, which is by speaking your reply aloud."

But there are other alternatives for communication other then email:

http://www.glassappsource.com/google-glass-features/google-glass-email-messaging.html

warspyking
  • 3,045
  • 4
  • 20
  • 37
0

Send the message content from the glass to your app, then execute the Intent you are attempting to use, but execute it from the phone.

Unfortunately there is no simple way to talk to your phone from glass, but there are a few examples on how to do it, one of which you can find documented on this other SO question.

Google Glass GDK: How to Communicate with Android Device

Send the

Intent.EXTRA_EMAIL, "recipient@example.com" Uri.parse("mailto:" + "recipient@example.com") Intent.EXTRA_SUBJECT, "xxxxxxxxxxxx" Intent.EXTRA_TEXT, "xxxxxxxxxxxxxxxxx"

to the phone, then go on as you would normally.

Note, this also requires a phone app. There is NO way to do this from glass independently if you dont want to request the users account information, including password.

Community
  • 1
  • 1
r2DoesInc
  • 3,759
  • 3
  • 29
  • 60