Note
This API has been available since API level 12.
This API has been available since API level 12.
An intent is an abstract description of an operation to be performed. Intent manager is a native service to handle the intent.
There are two types of intent:
Intent manager has roles to handle intents and manage handlers.
When the requester calls the start API with an intent, intent manager finds the suitable handler in the handler pool. Normally, handler is an app, so intent manager calls the launch API in the SAM to launch the (handler) app. The intent object is passed to application through launch params object
Sometimes, requester wants to get result from the handler. In such case, requester should subscribe to the start API to get the subscription message from the handler. Intent manager sends subscription message when the handler calls the sendResult API.
Requester can subscribe to the result by using the subscribeResult API also.
Steps to support intent - application
$ vi /usr/palm/applications/com.webos.app.enactbrowser/appinfo.json
{
....
"mimeTypes": [
{
"mime": "text/html",
"extension": "html",
"stream": true
},
{
"scheme": "http"
},
{
"scheme": "https"
}
],
"intentFilters": [
{
"actions": ["action_url", "action_uri"],
"uris": ["http://youtube.com", "http://", "https://"]
}
],
....
}
$ restart sam
$ restart com.webos.service.intent
$ luna-send -f -n 1 luna://com.webos.service.applicationmanager/getAppInfo '{ "id": "com.webos.app.enactbrowser"}'
Response:
{
"appId": "com.webos.app.enactbrowser",
"returnValue": true,
"appInfo": {
....
"intentFilters": [
{
"uris": [
"http://youtube.com",
"http://",
"https://"
],
"actions": [
"action_url",
"action_uri"
]
}
],
....
}
}
# luna-send -f -n 1 luna://com.webos.service.intent/query '{ "intent": { "action": "action_url", "uri":"http://google.com"}}'
Response:
{
"returnValue": true,
"handlers": [
{
"name": "com.webos.app.enactbrowser",
"intentFilters": [
{
"uris": [
"http://youtube.com",
"http://",
"https://"
],
"actions": [
"action_url",
"action_uri"
]
}
]
}
]
}
$ luna-send -f -n 1 luna://com.webos.service.intent/start '{ "intent": { "action": "action_url", "uri":"http://google.com"}}'
Response:
{
"intentId": 10,
"returnValue": true
}
For a list of supported intents, see the following webOS Intents table.
Intents must be specified in the following form:
{
"action":"{action}",
"uri":"{uri}",
"extra":{
...
}
}
Intent | Action | URI (format) | Extra | Examples (snippet of 'appinfo.json' file) |
---|---|---|---|---|
View URI (browser) | view | http://{url} | Example 1 - Ability to view all URIs starting with http and https. "intentFilters":[ Example 2 - Ability to view the 2 URIs mentioned below. "intentFilters":[ | |
View map (navigation) | view | geo:// | Example 1 - Ability to view all map locations. "intentFilters":[ Example 2 - Examples of other uris:
| |
View specific page (application) | view | app://{appId}/{path} | Example - Ability to open specific page of settings app "intentFilters":[ | |
Play media (video/audio) | view | file://{absolute_path} | Example - Ability to play specific file (works with 'mimeTypes' specified in appinfo.json file) "intentFilters":[ |
API level 12
Clients can get handlers by calling the API.
Name | Required | Type | Description |
---|---|---|---|
intent | Optional | Object: intent | Details of the intent. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorText | Optional | String | Indicates the reason for the failure of the operation. |
handlers | Required | Object array: handler | Please refer the handler object in the object section. |
Example : See all handlers
# luna-send -f -n 1 luna://com.webos.service.intent/query '{}'
Response:
{
"returnValue": true,
"handlers": [
{
"sessionId": "34117815-8721-4370-9cd3-ba74ff7349f5",
"name": "bareapp",
"intentFilters": [
{
"actions": [
"action_test"
]
}
]
},
....
{
"sessionId": "b51ca1c7-8d20-4ac0-87e1-62b41162d1da",
"name": "com.webos.app.volume",
"intentFilters": [
]
}
]
}
Example : Explicit Intent
# luna-send -f -n 1 luna://com.webos.service.intent/query '{
"intent":{
"name":"bareapp"
}
}'
Response:
{
"returnValue": true,
"handlers": [
{
"sessionId": "34117815-8721-4370-9cd3-ba74ff7349f5",
"name": "bareapp",
"intentFilters": [
{
"actions": [
"action_test"
]
}
]
},
{
"sessionId": "b51ca1c7-8d20-4ac0-87e1-62b41162d1da",
"name": "bareapp",
"intentFilters": [
{
"actions": [
"action_test"
]
}
]
}
]
}
Example : Implicit Intent
# luna-send -f -n 1 luna://com.webos.service.intent/query '{
"intent":{
"action":"action_test"
}
}'
Response:
{
"returnValue": true,
"handlers": [
{
"sessionId": "34117815-8721-4370-9cd3-ba74ff7349f5",
"name": "bareapp",
"intentFilters": [
{
"actions": [
"action_test"
]
}
]
},
{
"sessionId": "b51ca1c7-8d20-4ac0-87e1-62b41162d1da",
"name": "bareapp",
"intentFilters": [
{
"actions": [
"action_test"
]
}
]
}
]
}
API level 12
Enables the handlers to reply with the results.
Note: Also refer 'subscribeResult' API.
Name | Required | Type | Description |
---|---|---|---|
intentId | Required | Number | Indicates the intent ID used in the sendResult and subscribeResult. |
result | Optional | String | Indicates the result string which is provided by the handler. |
intent | Optional | Object: intent | Details of the intent. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
errorText | Optional | String | Indicates the reason for the failure of the operation. |
Example : Without extra info
# luna-send -n 1 -f luna://com.webos.service.intent/sendResult '{
"intentId":33,
"result":"ok"
}'
Response:
{
"returnValue": true,
"intentId": 33
}
Example : With extra info
# luna-send -n 1 -f luna://com.webos.service.intent/sendResult '{
"intentId":33,
"result":"ok",
"intent":{
"extra":{
"data":true
}
}
}'
Response:
{
"returnValue": true,
"intentId": 33
}
API level 12
Starts the handlers based on the intent information provided in the request payload.
Please refer 'subscribeResult' API for subscription payload.
Name | Required | Type | Description |
---|---|---|---|
intent | Optional | Object: intent | Details of the intent. |
subscribe | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
errorText | Optional | String | Indicates the reason for the failure of the operation. |
intentId | Required | Number | Indicates the Intent ID. |
None
API level 12
All running intents have their own 'intentId'. Of course, handlers can reply results thought 'intentId'.
Other component including requester can subscribe the results with this API.
Name | Required | Type | Description |
---|---|---|---|
intentId | Required | Number | Indicates the intent ID. |
subscribe | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Optional | String | Indicates if subscribed to get the notifications. Possible values are:
|
errorText | Optional | String | Indicates the reason for the failure of the operation. |
intentId | Required | Number | Indicates the intent ID. |
Name | Required | Type | Description |
---|---|---|---|
returnValue | Required | Boolean | Indicates the status of the operation. Possible values are:
|
subscribed | Optional | Boolean | Indicates if subscribed to get the notifications. Possible values are:
|
errorText | Optional | String | Indicates the reason for the failure of the operation. |
intentId | Required | Number | Indicates the intent ID which used in sendResult and subscribeResult |
result | Optional | String | Indicates the result string provided by the handler. |
intent | Optional | Object: intent | Please refer the intent object in the object section. |
from | Optional | String | Indicates the handler's luna ID. |
Example scenario
# luna-send -i -f luna://com.webos.service.intent/subscribeResult '{
"intentId":14,
"subscribe":true
}'
Response:
{
"returnValue": true,
"subscribed": true,
"intentId": 14
}
Subscription response:
{
"subscribed": true,
"result": "ok",
"intent": {
"extra": {
"data": true
}
},
"from": "com.webos.lunasend-36099",
"returnValue": true,
"intentId": 14
}
Indicates the application to handle the intent.
Name | Required | Type | Description |
---|---|---|---|
name | Required | String | Indicates the handler's luna bus ID. Usually, it is application id. Example: com.webos.service.intentmanager. |
sessionId | Optional | String | Indicates the handler's session ID. Example: navigation handler should be started under 'driver' session. |
intentFilters | Optional | Object array: intentFilter | Indicates the filter for the intent. |
Provides details of the intent.
Name | Required | Type | Description |
---|---|---|---|
name | Optional | String | Indicates the handler name. |
action | Optional | String | Indicates the action name. Note: Check List of intents for supported actions and URIs. |
uri | Optional | String | Indicates the uri pattern list. <scheme>://<host>:<port>/<path> Example: https://en.wikipedia.org/wiki/File_URI_scheme Note: Check List of intents for supported actions and URIs. |
mimeType | Optional | String | Indicates the mime type. Possible values are:
|
extra | Optional | Object | Indicates the additional parameter for the handler. |
Name | Required | Type | Description |
---|---|---|---|
actions | Optional | String array | Indicates the action list handled by the handler. Refer to intent object for a list of supported actions. Note: This can be empty if handler can't handle any kinds of action. |
mimeTypes | Optional | String array | Indicates the mimeType list handled by the handler. Refer to intent object for a list of supported mime types. Note: This can be empty if handler can't handle any kinds of mimeType. |
uris | Optional | String array | Indicates the uri list which handler can handle. Refer to intent object for a list of supported URIs. Note: This can be empty if handler can't handle any kinds of uri. |
Error Code | Error Text | Error Description |
---|---|---|
None | Failed to start intent | Failed to start intent because of internal error. |
None | Invalid parameter | Invalid parameters. |
None | Failed to parse intent | Failed to parse intent because required keys do not exist. |
None | Cannot find session | Cannot find session if given sessionId is not valid. |
None | Cannot find handler | Cannot find handler for given intent. |
None | 'intentId' is required parameter | Intent ID is a required parameter and must be provided. |
Contents