broadcast
The broadcast method sends an intent as a broadcast to registered receivers on the device.
Signature
async broadcast(
intent: Intent,
options?: { user?: SingleUserOrAll; receiverPermission?: string }
): Promise<void>
Parameters
The broadcast method takes two parameters:
intent: AnIntentobject describing the broadcastoptions(optional): Additional options including:user: Target a specific user for the broadcastreceiverPermission: Require receivers to hold a specific permission
Usage
await activityManager.broadcast({
action: "android.intent.action.BATTERY_CHANGED",
extras: {
level: 80,
scale: 100
}
}, {
user: 0,
receiverPermission: "android.permission.BROADCAST_STICKY"
});
The method returns a promise that resolves when the broadcast is sent.