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. String Optional Must be used with class.
extras Passes data to the invoked app. Array of objects Optional

See the description for extras in the table below.

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

Copy
/* Start the RFID utility service.
*/
 
Action.startService({
    package: "com.wavelink.velocity.rfid",
    class: "com.wavelink.velocity.RFIDService"
});