Action.startService()
Overview
Requests that a given Android service be started.
Services are started using intents. Intents are represented in JavaScript as an object with certain properties.
Intents must have at least an action or a class and package combination.
Added in version 2.0.7
Format
Action.startService(intent);
Intent object properties
Value | Description | Type | Required | Notes |
---|---|---|---|---|
action | A string representing the action to be performed. | String | Required | If the device has multiple apps registered to handle an action, a chooser dialog appears. |
categories | A list of required categories for the activity that is being started. | Array of strings | Optional | |
class | The name of the activity class to explicitly launch. | String | Optional | Must be used with package. |
package | The name of the application package to explicitly launch. If the devices are Android 11 or newer, you must include a package name. | String | Optional | On versions prior to Velocity 2.1.43, class must be used with package. |
data | The data URI that the action will operate on. | String | Optional | Must be a URI formatted string. For example: "http://www.wavelink.com/" "file:///sdcard/file.dat" In Android 11 or newer, the Velocity client has very limited access to the file system. Added in version 2.1.1 |
mime | The explicit MIME type of the data, or, if no data is specified, a request for a specific MIME type result. | String | Optional | Rarely used. For example: "text\plain" Added in version 2.1.1 |
extras | Passes data to the invoked app. | Array of objects | Optional |
See the description for extras in the table below. |
flags | A list of flags to be passed to the launch intent. | Array of strings | Optional |
The different types of flags can be found in the Microsoft .NET Android content ActivityFlags web page. Added in version 2.1.29 |
Extras
Value | Description | Type | Required | Notes |
---|---|---|---|---|
name | The name of the extra. | String | Required | |
value | The value of the extra. | String, Integer, Boolean, array of String, array of Integer, array of Boolean | Required | arrays added in version 2.1.11 |
type | The value type. One of "string", "integer", or "boolean". | String | Optional | If not specified, a type will be assigned based on the JavaScript type of the first value in arrays. For arrays, use the same three types to represent the type for all values in the array. |
Example
/* Start the RFID utility service.
*/
Action.startService({
package: "com.wavelink.velocity.rfid",
class: "com.wavelink.velocity.RFIDService"
});