Sunday, December 5, 2010

Calling and SMS through AIR application on Android Device

Adobe AIR 2.5 has support for two additional URI. Earlier we had mailto URI to navigate to system default email client. Similarly if you want to use system (Mobile) calling client you can do that using tel: URI or if you want to use system(Mobile) SMS client you can do that using sms: URI.

In this article, I will walk you through how we can access the mobile default calling / SMS client. To understand this article one should have knowledge of AS3 and deploying AIR application on mobile. If you are new to this technology (Air on Android). You can refer to my previous post to understand the deployment procedures.

Adobe has launched preview released of Flash Builder Burrito with Hero Flex SDK. We will use Hero Flex SDK to create this simple application.



See code snipped for the application below.



xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
title="Dial or SMS">

horizontalAlign="center"
paddingTop="10" paddingLeft="10" paddingBottom="10" paddingRight="10"/>




protected function callBtn_clickHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest("tel:"+telNumber.text));
}

protected function smsBtn_clickHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest("sms:"+telNumber.text));

}

]]>






width="100%"
restrict="0-9"/>
width="100%"
gap="5"
paddingBottom="5" paddingLeft="5" paddingRight="5" paddingTop="5"
verticalAlign="middle" horizontalAlign="right">
label="Call"
click="callBtn_clickHandler(event)"/>
label="SMS"
click="smsBtn_clickHandler(event)"/>




If you notice in the script tag, There is a navigateToURL method executed on Clicking of Call / SMS button.

Following code will trigger the default system calling client.

navigateToURL(new URLRequest("tel:"+telNumber.text));
This method will open up the dial panel of the mobile phone. See below image.

Following code will trigger the default system calling client.

navigateToURL(new URLRequest("sms:"+telNumber.text));
This method will open up the SMS panel of the mobile phone. See below image.


Note: Body and subject attributes is not supported in sms: URI like we do for the mailto: URI due to the limited support from the android API.

I hope this will help you.


Read more...