Action.sendBroadcast()

Overview

Sends an Android broadcast to all listening receivers.

Broadcasts are sent as intents. Intents are represented in JavaScript as an object with certain properties.

Added in version 2.0.7

Format

Action.sendBroadcast(intent);

Intent object properties

Value Description Type Required Notes
action A string representing the broadcast action. String Required  
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 additional data to the intent broadcast. 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

Copy
/* Sends a broadcast that is interpreted as a scan by Velocity.
*/
 
Action.sendBroadcast({
    action: "com.wavelink.intent.action.BARCODE",
    extras: [
        { name:"scan.symbology_type", value:"UPCA", type:"string" },
        { name:"scan.data_string", value:"1234567890", type:"string" },
    ]
});