www.webOShelp.net

Get the latest on:webOS Developers' RSS FeedwebOS Facebook page webOS Twitter Feed

Home Getting Started with webOS Mojo Application Services

Mojo Application Services

The Application Manager is a specific service that provides all application services to Mojo applications. Application services are services that involve launching other applications, whether they be core webOS applications or other third party applications.

The application manager, through one or both of its service methods Open and Launch, provides access to most of the application services. We'll look at each of these in more detail.

Open

This method is best used to display content when you don't know the specified type of content or best application available to handle it. In this case, the application manager will automatically launch the application most appropriate for that content type. This method accepts a single argument, a formatted URI for the content to display. The mime type of the referenced URI is used to identify the appropriate application to launch to handle the content indicated.

Example:

this.controller.serviceRequest('palm://com.palm.applicationManager', {
  method: 'open',
  parameters: {
    target: "https://www.irs.gov/pub/irs-pdf/fw4.pdf "
  },
  onFailure: this.onFailureHandler 
}); 

The target includes two parts. Everything up to and including "://" Palm calls "the command". Everything following the "://" is called the resource. The sequence of actions taken by the Application Manager upon receiving this service call is as follows:

  • In the above example, the command is https://. But before launching the Browser, the Application Manager will retrieve the http header and attempt to extract the resource type.
  • Since the URI specifies a file target, the Application Manager will try to match the file type to the resource list. It should find a match with com.palm.app.pdfviewer.
  • The file will be downloaded to /media/internal.
  • The PDFViewer will be launched with a file reference to the downloaded file.

If there's no header, the Application Manager downloads the file and attempts to match the file extension in the resource list. If a match is found, the associated application is launched with the file reference as a launch parameter. If there's no match, the Application Manager exits and returns an error code to the failure callback

The same process is used when streaming audio or video formats, but instead of downloading the content and then launching the application, the launch is done first and the content URI passed as an argument. The audio or video player handles the connection and data streaming in these cases; the data is never actually stored on device.

If the command is file:// then it's a local file reference and the Application Manager will use the file extension to launch the associated application.

Launch

The Launch method allows you to launch a specific application by application id, rather than having the Application Manager determine the appropriate application for you. To use this method, you need to know the format of the parameters that the application is expecting.

Example:

this.controller.serviceRequest('mojo://com.palm.applicationManager', {
  method: 'launch',
  parameters: {
    id: "com.palm.app.maps",
    params: {
      query: "950 W. Maude Ave, Sunnyvale,CA"}
    }
  }
});

Palm will be providing a "Command & Resource Table" that will include the full list of all supported content types and application resource handlers.

Let's take a look at some commonly-used applications services. Click here to view code examples of these application services in action.

Browser

We previously saw how a WebView widget could be used to display web content within an application. By launching the webOS browser instead of using a WebView, a user has access to the full browser functionality including creation of bookmarks, viewing multiple pages, etc. The browser can be launched to its default home page, or a specific URL.

Phone

The Phone application service allows the launch of the phone application with pre-populated with a specific phone number. However, the user will still have to press the "Dial" button to place the call (for obvious security reasons).

Camera

The camera application service allows the launch of a simplified camera interface to take a single picture, returning the file reference to the picture that was saved. Palm suggests that the only way to launch the camera from your application is through use of a Cross-App launch, which involves pushing a new scene with arguments that specify that the camera should be launched. When the scene is then popped, the camera application passes a response object to the to the calling scene's activate method.

Photos

The photos application is currently limited to launching the application to the default view where a user can choose between various albums and photos.

Maps

The map application can be used to display maps around locations specified by street address, latitude/longitude, or location query. Other options include map type and zoom level, as well as driving directions or business search results.

That covers Mojo Application Services. In the next (not quite) daily tutorial, we'll look into Palm Synergy services, which let you integrate your application with webOS Contacts, Email, Calendar and Messaging. Grab the www.webOShelp.net RSS feed to stay in the know!

Much of the information in this article was presented in Chapter 7 of Palm webOS by Mitch Allen.

 

1 Comment

Feed
  1. Does the camera part mean there will be no other way to interact with the camera stream (e.g. for an augmented reality application) :\?

Add Comment


    • >:o
    • :-[
    • :'(
    • :-(
    • :-D
    • :-*
    • :-)
    • :P
    • :\
    • 8-)
    • ;-)