Object: blackberry.launch
The blackberry.launch object provides methods that lets you access core and add-on BlackBerry® applications through JavaScript®. Depending on the application, you can either launch the application or open the application and create a new item, such as a calendar entry or a task, and prepopulate any of the entry fields. Although the methods of the blackberry.launch object can open and create new items for an application, changes are not made to the application without confirmation from the user. For example, if you use the blackberry.launch object to make a phone call to a specific phone number, the user is prompted to confirm whether the user wants to proceed with the call before the number is dialed. Similarly, if you create a new item for any application, the user must save the item before it is added to that application.
Parameters for the blackberry.launch methods are provided in the form of a single JSON object. For example, to open BlackBerry® Maps and display a set of coordinates, you could use the blackberry.launch.newMap() method as follows:
blackberry.launch.newMap({"latitude":4328915, "longitude":-8032480});
When a JSON object is identified as the parameter of a method, it is required. However, the members contained within the JSON object are all optional. For example, you can specify an empty JSON object as the parameter to a method, as long as the JSON object (identified by the braces) is present. For example:
blackberry.launch.newMap({});
blackberry.launch methods
|
Method name |
Description |
Availability |
|---|---|---|
|
Opens the Camera application. |
5.0 or later |
|
|
Opens the Video Camera application. |
5.0 or later |
|
|
Opens the Phone application to call the voice mail account that is associated with the BlackBerry® device. |
5.0 or later |
|
|
Creates a new appointment in the Calendar application. |
5.0 or later |
|
|
Adds a new contact to the Contacts list. |
5.0 or later |
|
|
Opens the BlackBerry® Maps application and displays the specified location. |
5.0 or later |
|
|
Creates a new memo in the Memo application. |
5.0 or later |
|
|
Opens the phone application to call a specific phone number. |
5.0 or later |
|
|
Creates a new SMS text message. |
5.0 or later |
|
|
Creates a new task in the Tasks application. |
5.0 or later |
Method: blackberry.launch.launchCamera()
Method: blackberry.launch.launchVideoRecorder()
Method: blackberry.launch.launchVoicemail()
Method: blackberry.launch.newAppointment()
The newAppointment() method creates a new appointment in the calendar application. The user must save the appointment before it is saved to the calendar.
JSON object members
Code sample: Creating a new appointment for the calendar application
// Define the start and end times as JavaScript Date objects
var startTime = new Date(2010,10,10,2);
var endTime = new Date(2010,0,1,3,29);
// Create the JSON object that defines all the appointment
// information as name-value pairs
var appointmentInfo = {
"summary":"Meet new VP"
"location":"Conference room 2"
"allDay":false
"start":startTime
"end":endTime
"freeBusy":1
"note":"Refreshments will be served."
};
// Create a new appointment with the new JSON object as a parameter
blackberry.launch.newAppointment(appointmentInfo);
Method: blackberry.launch.newContact()
The newContact() method creates a contact in the BlackBerry device user's contact list. The user must save the new contact before it is added to the contact list.
Syntax
blackberry.launch.newContact({ title, firstName, lastName,
company, jobTitle, email, workPhone, workPhone2, homePhone,
homePhone2, mobilePhone, pagerPhone, faxPhone, otherPhone,
pin, workAddress, homeAddress, birthday, anniversary,
webpage, user1, user2, user3, user4, note })
JSON object members
Member |
Type |
Description |
|---|---|---|
title |
String |
Specifies the contact's title, such as Mr, Mrs, or Dr. |
firstName, lastName |
String |
Specify the contact's first name and last name. |
company |
integer |
Specifies the organization that the contact belongs to. |
jobTitle |
String |
Specifies a job title for the contact. |
array |
Specifies an array of email addresses for the contact. The array contains a comma-separated list of strings, each representing an email address. The contents of the array are enclosed in brackets. For example: ["email1@company1.com", "email2@company2.com"] |
|
workPhone, workPhone2, homePhone, homePhone2, mobilePhone, pagerPhone, faxPhone, otherPhone |
String |
Specify assorted phone numbers for the contact. |
pin |
String |
Specifies a BlackBerry device PIN for the contact. |
workAddress, homeAddress |
Specify various addresses for the contact, represented by an Address JSON object. |
|
birthday, anniversary |
Date |
Specify important dates for the contact, represented by a JavaScript® Date object. |
webpage |
String |
Specifies a web page for the contact. |
user1, user2, user3, user4, note |
String |
Specify additional information for the contact. |
Code sample: Creating a new contact
var workAddress = {
"address1":"295 Phillip Street",
"city":"Waterloo",
"country":"Canada",
"stateProvince":"ON",
"zipPostal":"N2L3WE"
};
var bday = new Date(1978,3,22);
var contactInfo={
"title":"Ms"
"firstName":"Karen"
"lastName":"Moser"
"email":[ "too_cool@internet.com", "KM_2@work.com" ]
"pin":"2100000A"
"workAddress":workAddress
"birthDay":bday
};
blackberry.launch.newContact(contactInfo);
Method: blackberry.launch.newMap()
The newMap() method opens BlackBerry® Maps and displays a specified location on the map. You can specify a location using one of three following ways:
Syntax
blackberry.launch.newMap({ latitude, longitude })
OR
blackberry.launch.newMap({ address })
OR
blackberry.launch.newMap({ locationDocument })
JSON object members
Member |
Type |
Description |
|---|---|---|
latitude |
double |
Specifies the latitude in decimal degrees to five decimal places, multiplied by 100,000. A negative value indicates a southern latitude. For example, to indicate a latitude of 43°N, specify a value of 4,300,000. |
longitude |
double |
Specifies the longitude in decimal degrees to five decimal places, multiplied by 100,000. A negative value indicates a western longitude. For example, to indicate a longitude of 80°W, specify a value of -8,000,000. |
address |
Specifies address information, represented by an Address JSON object. |
|
locationDocument |
String |
Specifies an XML location document. This XML structure is specific to BlackBerry Maps. |
Code sample: Displaying a set of geographic coordinates in BlackBerry Maps
blackberry.launch.newMap({
"latitude":4346518,
"longitude":-8052237
});
var workAddress = {
"address1":"295 Phillip Street",
"city":"Waterloo",
"country":"Canada",
"stateProvince":"ON",
"zipPostal":"N2L3WE"
};
blackberry.launch.newMap({"address":workAddress});
blackberry.launch.newMap({
"locationDocument":"<lbs id=\"Waterloo\">
<location x=\"-8052237\" y=\"4346518\" label=\"Waterloo, ON\" description=\"Waterloo\" zoom=\"10\" \/>
<\/lbs>"
});
Method: blackberry.launch.newSMS()
Method: blackberry.launch.newPhoneCall()
JSON object members
Member |
Type |
Description |
|---|---|---|
dialString |
String |
Specifies the phone number to call. The phone number is specified as a string and must be enclosed by quotation marks. |
smartDialing |
Boolean |
When true, indicates that the phone application should apply the Smart Dialing options that the BlackBerry device user specified in the Phone options. Smart dialing permits the user to configure a default country code and area code for phone numbers. The phone application prepends these values automatically when it dials a phone number. |
Method: blackberry.launch.newTask()
JSON object members
Code sample: Creating a new task
// set the task completion date for one week from today
var currentDate = new Date();
var DateInMilliseconds = currentDate.getTime();
var completeDate = DateInMilliseconds + 604 800 000;
// Create a JSON object that specifies the task properties
var taskProperties = {
"summary":"Create new business proposal",
"status":0,
"priority":0,
"due":completeDate,
"note":"Complete this proposal on time!!"
};
// create a new task with the new JSON object as a parameter
blackberry.launch.newTask(taskProperties);
JSON Object: Address
The Address object is a JSON object that contains address information used by the methods of the blackberry.launch object.
JSON object members
Member |
Type |
Description |
|---|---|---|
address1 |
String |
Specifies the street address. |
address2 |
String |
Specifies additional address information. |
city |
String |
Specifies the city that the address is located in. |
stateProvince |
String |
Specifies the state or province that the address is located in. |
country |
String |
Specifies the country that the address is located in. |
zipPostal |
String |
Specifies the zip code or postal code of the address. |