Air for Android: Text Messages, Emails, and Phone Calls

Why do you build mobile apps on a phone? Well obviously to make phone calls, send text messages, and email your buddies random links to sites that should have their content prefixed with NSFW. You may worry that this is difficult to send the information around the Android system. If so, then you obviously don’t have faith in Adobe and how easy they can make something. Have you not seen the content assist videos?

Anyways.

Here is the long and the short to making phone calls, sending emails, and texting from your application.

If you are starting with this post I recommend actually starting with a previous post introducing AIR for Android Development. There is a ANT file there that you will want to have.


Website
Have you ever navigated to a website? Yup, navigateToURL…

navigateToURL(new URLRequest("http://unitedmindset.com/jonbcampos"));

Phone Call
Adobe has made it so easy that the same idea holds true to phone calls…

navigateToURL(new URLRequest("tel:5555555555"));

Text Message
And text message…

navigateToURL(new URLRequest("sms:5555555555"));

Email
And wouldn’t you know… email…

navigateToURL(new URLRequest("mailto:myemail@gmail.com"));

Additional Information
You can add additional information like email subject, text message body and whatnot right in the link. Feel free to play with it and integrate your application.

Share

Comments (23)

derek knoxSeptember 28th, 2010 at 12:30 pm

That is so sick! I would not have imagined it being that simple. Very cool Adobe, very cool!

[...] Air for Android: Text Messages, Emails, and Phone Calls Hogyan küldjünk Androidon futó Flash-b?l E-mailt, SMS-t és hogyan indítsunk hívást. [...]

reelfernandesOctober 10th, 2010 at 1:23 am

I believe you can even do this using basic HTML/Javascript web apps. Doesn’t this method simply delegate the phonecall/sms/email to the OS’s default handler for each? By the title, I was kinda hoping to read about email/SMS/phonecalls from within your own app. Still cool though.

ixustruestoriesNovember 1st, 2010 at 2:48 am

sms:555555555?body=Hello and android put the entire text in the send field and does not populate the body text, anyone know why?

Jonathan CamposNovember 1st, 2010 at 9:12 am

@ixustruestories I’ve tried it a few different ways and each time I get an “invalid recipient” error. If you figure out the trick I’d be interested to find out.

MichaelNovember 7th, 2010 at 4:07 am

thanks for posting these, ofc bookmarked!

Chris MooreNovember 9th, 2010 at 1:52 pm

Look at this page which actually references you Jonathan. ;) http://www.adobe.com/newsletters/edge/november2010/articles/article1/index.html

This following snippet of the article is taken from their under the section “Triggering built-in phone features”

In my application, I take advantage of the Android phone’s ability to send e-mail to enable users to share their gamer entries or profile name easily. Triggering e-mail is incredibly simple and can be done with as little as one line of code using the navigateToURL() method. Below is the code from the GamerProfile view that triggers the e-mail application with the provided subject and body details:

protected function emailEntry():void {
var subject:String = “Check out my XBox Live Profile”;
var body:String = model.info.gamertag + ” from ” + model.profile.getFullLocation()
+ ” wants to be your friend on XBox Live.”;
navigateToURL(new URLRequest(“mailto:?subject=” + subject + “&body=” + body));
}

Jonathan CamposNovember 9th, 2010 at 1:56 pm

@Chris very cool!

Tekin TatarDecember 9th, 2010 at 8:44 am

is there a method to attach a file to the e-mail with mailto. I am trying to attach an image but i could not figure out.

Jonathan CamposDecember 9th, 2010 at 9:20 am

@Tekin There isn’t a way that I’ve heard how to do this with the mailto link. You could easily have the user attach an image or upload an image and provide the link, but not add an attachment.

AndroidFebruary 10th, 2011 at 4:39 am

The phone overall was very nice. Didn’t weight much and the touch screen was responsive. The Android OS ran well. I liked it overall. It being unlocked and cheap along with the Android OS made it a good buy I thought at the time. The problem I had was that while the features were nice I could not get the phone to update via the official tools. Others had this problem all over the world with this particular phone. Some had to wait for their cell providers to push out the update but those that bought it unlocked from various places had issues at the time. The choice I was left with at the time was to install the update myself. A process if done wrong could turn the phone into a paperweight. With no US warranty I didn’t feel safe in doing so. So in the end I returned it and thankfully because the device was fulfilled by Amazon.com I was able to get my money back. If I had the chance to buy the phone again but with the update already installed I would as I am a fan of the Android OS and did like the phone overall. However I would warn people that if they do want to update and don’t feel like taking certain risk to perhaps look for a different phone or one with a US warranty.

Jason RFebruary 27th, 2011 at 1:37 pm

Problem with mailto.
urlString =”mailto:”+sendTo+”?subject=”+emailSubject+”&body=Generated call report\n \n”+messagePart1+”\n \n”+messagePart2;

what is sent to the compose screen is the email address, subject, but in the body only
“Generated call report” . The same string is displayed elsewhere with no problem.
This is only happening with one downloaded app to a droid incredible. All others, including other incredibles, work fine. Could this be a setting on that phone? I even tried changing the line breaks to \r\n but no luck.

Any thoughts?

jonbcamposFebruary 27th, 2011 at 1:46 pm

@Jason The big issue with Android development is all the little 2bit hackers builting custom mods but don’t really do the proper testing on their mod. I go into that rant to ask if the one failing incredible has something custom to it?

[...] Air for Android: Text Messages, Emails, and Phone Calls by Jon Campos - http://www.unitedmindset.com/jonbcampos/2010/09/28/air-for-android-text-messages-emails-and-phone-ca… [...]

Rishi kumarSeptember 12th, 2011 at 5:08 am

how to attach file in email need help

jonbcamposSeptember 12th, 2011 at 9:45 am

@Rishi currently this feature isn’t supported. you could do it with a native extension.

AndreiNovember 18th, 2011 at 6:39 am

How to attach an mp3 file in SMS. I know it’s possible by using native send sms application, but how to call that native application with the file already attached? Thank you!

jonbcamposNovember 18th, 2011 at 6:56 am

@andrei by default you cant. You’ll need to use a native extension. I believe I saw one out there on the Adobe extensions page. Could be wrong though. I know you’d need a native extension for that functionality.

AndreiNovember 18th, 2011 at 7:26 am

I forgot to mention that I’m working on a flex mobile project for android OS. Maybe there is a parameter to be set when calling “new URLRequest(“sms:” phone-number)”. I’ve seen some blog posts where the URLRequest passes, beside the phone number, a text representing sms body. thank you!

CesareDecember 16th, 2011 at 3:23 am

Can you send html emails?

jonbcamposDecember 16th, 2011 at 9:51 am

@cesare honestly I haven’t tried but I don’t see why not.

ThijsMarch 1st, 2012 at 5:44 am

Anyone know of a good way to detect if “tel:” is supported by the device (so if the device can make calls or not)? I found the method below but it’s not foolproof of course.

/**
* Calculates the screen diagonal of the device and returns true if the
* screen diagonal is greater than 6 inches, which most devices without
* phone capabilities are.
*
* @return Boolean indicating whether this application is running on a
* tablet (without phone capabilities).
*/
public static function get isTablet():Boolean
{
var screenDiagonal:Number = Math.sqrt( Math.pow(
Capabilities.screenResolutionX / Capabilities.screenDPI, 2 ) +
Math.pow( Capabilities.screenResolutionY / Capabilities.screenDPI, 2 ));

return ( screenDiagonal > 6 );
}

jonbcamposMarch 1st, 2012 at 9:37 am

@Thijs you could create an ANE that reads the phonestate prior to use. But I agree other than that there isn’t much of a way to check.

Leave a comment

Your comment