Broadcasts¶
Sending Android intent broadcasts (adb shell am broadcast) to a connected device.
send_broadcast
¶
Send an Android intent broadcast to a device: adb shell am broadcast.
Models the intent semantically (action/component/package/extras) rather than accepting a raw command string — see the module docs for why this server never exposes arbitrary shell arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serial
|
str
|
The target device's adb serial (see list_connected_devices). |
required |
action
|
str
|
The broadcast's Intent action, e.g.
"android.intent.action.MY_ACTION" ( |
required |
component
|
str | None
|
Restrict delivery to one explicit receiver, in
"package/class" form, e.g. "com.example.app/.MyReceiver" ( |
None
|
package
|
str | None
|
Restrict delivery to receivers declared by one package
( |
None
|
user_id
|
int | None
|
Send the broadcast as one specific Android user ( |
None
|
receiver_permission
|
str | None
|
Require receivers to hold this permission to
receive the broadcast, e.g. "com.example.MY_PERMISSION"
( |
None
|
extras
|
list[BroadcastExtra] | None
|
Simple scalar Intent extras to attach ( |
None
|
Returns:
| Type | Description |
|---|---|
BroadcastResult
|
The broadcast's completion info: the serial/action/component/ package/user_id/receiver_permission sent, the parsed result_code (and result_data/result_extras when a receiver set them), and the raw am output. |
Error handling
Propagates the same way most tools do (unlike check_adb_available): if the adb binary itself can't be found or is unresponsive, or the serial doesn't match a connected device, that surfaces as an actual tool error. A malformed component string (not "package/class" shape) raises COMPONENT_NOT_FOUND; a protected action the caller isn't allowed to send raises PERMISSION_DENIED; any other ActivityManager failure raises a generic BACKEND_ERROR. A well-formed component or package that simply doesn't match any installed receiver is NOT an error — Android resolves receivers at delivery time, so that case completes normally with result_code=0.
Example
Called with serial="emulator-5554", action="android.intent.action.MY_ACTION". A typical response:
{
"status": "success",
"message": "Broadcast 'android.intent.action.MY_ACTION' completed on emulator-5554 (result=0).",
"data": {
"serial": "emulator-5554",
"action": "android.intent.action.MY_ACTION",
"component": null,
"package": null,
"user_id": null,
"receiver_permission": null,
"result_code": 0,
"result_data": null,
"result_extras": null,
"output": "Broadcasting: Intent { act=android.intent.action.MY_ACTION }\nBroadcast completed: result=0\n"
},
"error": null
}