22 November 2010
Intermediate
A Uniform Resource Identifier (URI) is a string that is used to identify a resource. For example, in a web page, if you click an e-mail ID embedded with the mailto URI, the default e-mail client in your system opens with the e-mail ID in the To list. Adobe AIR 2.5 allows you to use two new URI schemes, tel: and sms: , to access the system phone dialer and system SMS application.
Note that the tel: and sms: URI schemes behave differently on different devices and different platforms. For example, if the SMS program is not properly configured on a device, the sms: URI does not work. Likewise, on the Android platform, the URI scheme must be specified in lowercase.
In this article, you will learn to use:
tel: URI scheme with the navigateToURL() functionsms: URI scheme with the navigateToURL() functionsms: and tel: URI schemes as hyperlinks in a text fieldTo use the tel:URI scheme to launch the system phone dialer, create a URLRequest object containing the telephone number and pass the object to the navigateToURL method in the flash.net package. The following example illustrates how to do this:
public function call():void
{
const callURL:String="tel:1234567890";
var targetURL:URLRequest = new URLRequest(callURL);
navigateToURL(targetURL);
}
When the function is run on a phone, the default dialer is launched with the telephone number already entered. (The user must still initiate the phone call by pressing the call button.)
Figure 1 shows the way a tel: URI opens the telephone dialer on an Android mobile phone.
You can use the sms: URI scheme exactly the same way you use the tel: URI scheme:
public function sms():void
{
const callURL:String="sms:1234567890";
var targetURL:URLRequest = new URLRequest(callURL);
navigateToURL(targetURL);
}
When the function is run on a phone, the default SMS client is launched with the telephone number already entered as shown in Figure 2.

Note: Setting the body text in the sms: URL is not currently supported due to a limitation of the Android operating system.
A TextField object can display simple HTML content. You can use tel: and sms: URI schemes in HTML hyperlinks. For example, the following code creates a text field displaying a hyperlink:
var call:TextField = new TextField();
call.htmlText ="<a href='tel:1234567890'>Call</a>";
When the user taps the Call link, the application launches the system phone dialer. In the same way, you can create hyperlinks containing an sms: URI.
In this article, you learned about using the tel: and sms: URIs in your applications. For more information, refer to ActionScript APIs specific to mobile AIR applications in the online Help documentation.