Sending broadcast
suggest changeIt is possible to send a broadcast to a BroadcastReceiver with adb.
In this example we are sending a broadcast with action com.test.app.ACTION and string extra 'foo'='bar':
adb shell am broadcast -a com.test.app.ACTION --es foo "bar"
You can put any other supported type in the extras, not only strings:
--ezboolean,--eiinteger,--ellong,--effloat,--euuri,--eiaint array (separated by,),--elalong array (separated by,),--efafloat array (separated by,),--esastring array (separated by,)
To send an intent to a specific package or class, the -n or -p parameter can be used. Sending to a package:
-p com.test.app
Sending to a specific component (SomeReceiver in the 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