Sending broadcast
suggest changeIt’s possible to send broadcast to BroadcastReceiver
with adb
.
In this example we are sending broadcast with action com.test.app.ACTION
and string extra in bundle 'foo'='bar'
:
adb shell am broadcast -a action com.test.app.ACTION --es foo "bar"
You can put any other supported type to bundle, not only strings:
–ez - boolean –ei - integer –el - long –ef - float –eu - uri –eia - int array (separated by ‘,’) –ela - long array (separated by ‘,’) –efa - float array (separated by ‘,’) –esa - string array (separated by ‘,’)
To send intent to specific package/class -n
or -p
parameter can be used. Sending to package:
-p com.test.app
Sending to a specific component (SomeReceiver
class in com.test.app package
):
-n com.test.app/.SomeReceiver
Useful examples:
- Sending a “boot complete” broadcast
- Sending a “time changed” broadcast after setting time via adb command
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents