Sending Broadcast from ADB to Emulator

If you are testing an app and want to send a broadcast of an Intent from ADB, read through.

To enable root access, use an emulator image like
Google APIs Intel x86 Atom System Image
not
Google Play Intel x86 Atom System Image
To test it, run adb root. It should say
restarting adbd as root
or
adbd is already running as root
not
adbd cannot run as root in production builds

 Now either from a terminal app or from Terminal tab in Android Studio, type the following:

adb shell

su

am broadcast -a android.intent.action.BOOT_COMPLETED


You should get the following output:

Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED }
Broadcast completed: result=0





Comments