# Application Manager

The Application Manager provides a service to implicitly launch a resident application based on the requested command and resource types, or to explicitly launch a specified application. The framework determines the appropriate handler when using the Application Manager's open method with the command and the resource types encoded in URI-format. Alternatively, you can launch an application directly by invoking the launch method and specifying the requested application in the id property and provide the appropriate arguments in the parameter property.

## URI

The URI is as follows:

>     palm://com.palm.applicationManager

## Methods

This section describes the following methods:

- open
- launch

### open

The Application Manager is called with a standard parameter block that primarily includes a URI string assigned to the target property. It matches the prefix of the URI string against the list of supported commands, shown in the resource-command-types section, and launches the target application passing the rest of the URI string as a launch parameter.

If the command is file, it is a local file reference and the AppManager uses the file extension to launch the associated application if there is one.

If the command is http or https, before launching the browser, the AppManager retrieves the http header and attempts to extract the resource type. If it is a file target, it tries to match the type to the resource list as follows:

- If there is a match, it downloads the file and launches the associated application with the file reference as a launch parameter.
- If there is no header, it still downloads the file and attempts to match the file extension in the resource list.
  - If that matches, the associated application launches with the file reference as a launch parameter.
  - If there is ultimately no match, the Application Manager exits and returns an error code if an onFailure function is supplied.

Required parameter:

- target

#### Parameters

Parameter | Type | Description
--- | --- | ---
target | string | A standard URI format of the form command://url, where command_ is one of the supported commands, and the url is an argument string in conventional url notation. In the case that the command is a webOS application, the url argument string is specified by that application. For details, see the Services API for the specified application.

#### Return Handling

onSuccess

An object is returned with the following attributes:

Attribute | Type | Description
--- | --- | ---
processId | string | The process ID of the launched application.
returnValue | boolean | true

onFailure

An object is returned with the following attributes:

Attribute | Type | Description
--- | --- | ---
errorText | string | A string representing the error for display if needed.
returnValue | boolean | false

#### Example - launch the Palm calendar app

>     this.controller.serviceRequest('palm://com.palm.applicationManager', {
>       method: 'open',
>       parameters: {
>           id: 'com.palm.app.calendar',
>           params: {}
>       }
>     })

### launch

Launches the application indicated in the parameters.id property with the params JSON dependent on the application called.

Required parameter:

- id

#### Parameters

Parameter | Type | Description
--- | --- | ---
id | string | The application ID specified in the Services API for the intended application.
params | object | JSON object containing the parameters for the target application; specified in the Services API.

#### Return Handling

onSuccess

An object is returned with the following attributes:

Attribute | Type | Description
--- | --- | ---
processId | string | The process ID of the launched application.
returnValue | boolean | true

onFailure

An object is returned with the following attributes:

Attribute | Type | Description
--- | --- | ---
errorText | string | A string representing the error for display if needed.
returnValue | boolean | false

#### Example - open the app catalog to the Pandora page

>     this.controller.serviceRequest('palm://com.palm.applicationManager', {
>       method: 'launch',
>       parameters: {
>           id: 'com.palm.app.findapps',
>           params: {
>               scene : 'page',
>               target: 'http://developer.palm.com/appredirect/?packageid=com.palm.pandora'
>           }
>       }
>     });

## Command and Resource Types

>     "resources":[
>       { "extn":"htm", "mime":"text/html", "appId":"com.palm.app.browser", "streamable":true },
>       { "extn":"html", "mime":"text/html", "appId":"com.palm.app.browser", "streamable":true },

>       { "extn":"pdf", "mime":"application/pdf", "appId":"com.palm.app.pdfviewer", "streamable":false },
>       { "extn":"txt", "mime":"application/txt", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"doc", "mime":"application/doc", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"doc", "mime":"application/msword", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"xls", "mime":"application/xls", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"xls", "mime":"application/excel", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"xls", "mime":"application/vnd.ms-excel", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"xls", "mime":"application/x-excel", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"xls", "mime":"application/x-msexcel", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"ppt", "mime":"application/ppt", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"ppt", "mime":"application/mspowerpoint", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"ppt", "mime":"application/powerpoint", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"ppt", "mime":"application/vnd.ms-powerpoint", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"ppt", "mime":"application/x-mspowerpoint", "appId":"com.palm.app.docviewer", "streamable":false },

>       { "extn":"docx", "mime":"application/doc", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"xlsx", "mime":"application/xls", "appId":"com.palm.app.docviewer", "streamable":false },
>       { "extn":"pptx", "mime":"application/ppt", "appId":"com.palm.app.docviewer", "streamable":false },

>       { "extn":"pem", "mime":"application/pem", "appId":"com.palm.app.certificate", "streamable":false },
>       { "extn":"p12", "mime":"application/p12", "appId":"com.palm.app.certificate", "streamable":false },
>       { "extn":"pfx", "mime":"application/pfx", "appId":"com.palm.app.certificate", "streamable":false },
>       { "extn":"der", "mime":"application/der", "appId":"com.palm.app.certificate", "streamable":false },
>       { "extn":"crt", "mime":"application/crt", "appId":"com.palm.app.certificate", "streamable":false },
>       { "extn":"cer", "mime":"application/cer", "appId":"com.palm.app.certificate", "streamable":false },
>       { "extn":"crl", "mime":"application/crl", "appId":"com.palm.app.certificate", "streamable":false },

>       { "extn":"mp4", "mime":"video/mp4-generic", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"mp4", "mime":"video/quicktime", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"mp4", "mime":"video/mp4", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"mp4", "mime":"video/mpeg4", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"m4v", "mime":"video/mp4-generic", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"m4v", "mime":"video/quicktime", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"m4v", "mime":"video/mp4", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"m4v", "mime":"video/mpeg4", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"3gp", "mime":"video/3gp", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"3gpp", "mime":"video/3gp", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"3g2", "mime":"video/3gpp2", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"3gp2", "mime":"video/3gpp2", "appId":"com.palm.app.videoplayer", "streamable":true },
>       { "extn":"sdp", "mime":"application/sdp", "appId":"com.palm.app.videoplayer", "streamable":true },

>       { "extn":"3gp", "mime":"audio/3gpp", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3gpp", "mime":"audio/3gpp", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3ga", "mime":"audio/3gpp", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3gp", "mime":"audio/3ga", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3gpp", "mime":"audio/3ga", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3ga", "mime":"audio/3ga", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3g2", "mime":"audio/3gpp2", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"3gpp2", "mime":"audio/3gpp2", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"amr", "mime":"audio/amr", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"amr", "mime":"audio/x-amr", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/mpa", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/mp3", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/x-mp3", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/x-mpg", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/mpeg", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/mpeg3", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/mpg3", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"mp3", "mime":"audio/mpg", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },

>       { "extn":"mp4", "mime":"audio/mp4", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"m4a", "mime":"audio/mp4", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"m4a", "mime":"audio/m4a", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"aac", "mime":"audio/aac", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"aac", "mime":"audio/x-aac", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"aac", "mime":"audio/mpeg", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"aac", "mime":"audio/mp4a-latm", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"wav", "mime":"audio/wav", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"wav", "mime":"audio/wav", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },

>       { "extn":"pls", "mime":"audio/x-scpls", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"m3u", "mime":"audio/mpegurl", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },
>       { "extn":"m3u", "mime":"audio/x-mpegurl", "appId":"com.palm.app.streamingmusicplayer", "streamable":true },

>       { "extn":"mcd", "mime":"application/x-pcs-mcd+xml", "appId":"com.palm.mobitv.app.sprinttv", "streamable":true }
>     ],

>     "commands":[
>       { "url":"^mailto:", "appId":"com.palm.app.email" },
>       { "url":"^im:", "appId":"com.palm.app.messaging" },
>       { "url":"^sms:", "appId":"com.palm.app.messaging" },
>       { "url":"^contact:", "appId":"com.palm.app.contacts" },
>       { "url":"^chatWith:", "appId":"com.palm.app.messaging" },
>       { "url":"^opencontact:", "appId":"com.palm.app.contacts" },
>       { "url":"^mojave:", "appId":"com.palm.app.mojave" },
>       { "url":"^https?:", "appId":"com.palm.app.browser"},
>       { "url":"^data:", "appId":"com.palm.app.browser"},
>       { "url":"^tel:", "appId":"com.palm.app.phone"},
>       { "url":"^rtsp[tu]?:", "appId":"com.palm.app.videoplayer"},
>       { "url":"^mobi:", "appId":"com.palm.app.videoplayer"},
>       { "url":"^mapto:", "appId":"com.palm.app.maps"},
>       { "url":"^maploc:", "appId":"com.palm.app.maps"},
>       { "url":"^rtsp[tu]?:", "appId":"com.palm.app.videoplayer"},
>       { "url":"^mobi:", "appId":"com.palm.app.videoplayer"},
>       { "url":"^sprinttv:", "appId":"com.palm.mobitv.app.sprinttv" }
>     ]}