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.
Now either from a terminal app or from Terminal tab in Android Studio, type the following:
adb shell
su
You should get the following output:
Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED }
Broadcast completed: result=0
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 sayrestarting 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_COMPLETEDYou should get the following output:
Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED }
Broadcast completed: result=0
Comments
Post a Comment