getServiceObject()

Description:

The getServiceObject method creates an object that is used to access the services made available through a Service API. This object is referred to as a "service object".

Syntax:

so = device.getServiceObject(provider, interface);

Arguments:

  • provider:

    This is a text string that defines the service provider name, that is, the name of the type of service object to create.

  • interface:

    This is a text string that defines the supported interface for the specified service provider.

Table: Service API providers and interfaces

Service API

Provider

Interface

AppManager

Service.AppManager

IAppManager

Calendar

Service.Calendar

IDataSource

Contacts

Service.Contact

IDataSource

Landmarks

Service.Landmarks

IDataSource

Location

Service.Location

ILocation

Logging

Service.Logging

IDataSource

Media Management

Service.MediaManagement

IDataSource

Messaging

Service.Messaging

IMessaging

Sensor

Service.Sensor

ISensor

SystemInfo

Service.SysInfo

ISysInfo

Return value:

If the call succeeds, the getServiceObject method returns a service object; otherwise it returns undefined.

Remarks:

  • The getServiceObject method is a factory method found on the device object.

  • To ensure backward compatibility, always check in your JavaScript code that the device object exists before calling the getServiceObject method. For example:

    if (device != "undefined")
      device.getServiceObject("Service.MediaManagement", "IDataSource");
    

Example code:

The following example creates a service object for the Media Management Service API:

var so = device.getServiceObject("Service.MediaManagement", "IDataSource");