Using Services

All service calls are asynchronous operations. Each application service has a distinct service name, and exposes one or more named methods. Most application services will launch an application in its own card and will not return to the calling application. Device and cloud services will typically return some data or result to the calling application through a callback function defined by the calling application. Some services, such as Location tracking, will return data in a series of calls to the callback function. You need to design your applications with this asynchronous interface in mind.

There are additional constraints when you are using services in background applications; these will be covered in Chapter 10. Background applications must moderate service use to conserve CPU and battery resources, plus with limited to no user interaction, the background application must handle service responses directly and use notifications and the dashboard to communicate with the user.

In many cases, the application should limit or stop service requests when minimized or in the background. For example, a game that takes accelerometer input should stop tracking the accelerometer when minimized. Without any visible display, there is no value in expending resources to collect that data.

Service Overview

Most services are Linux servers registered on the Palm bus, wrapped and accessed through the Mojo.Service.Request object. Application services are all accessed through a single ...

Get Palm webOS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.