I want to debug a BroadcastReceiver
which should start its onReceive method when the action android.intent.action.BOOT_COMPLETED
is triggered. I have read several sources like
- How to debug BOOT_COMPLETE broadcast receiver's "Force Close" crashes?
- Android adb shell am broadcast: Bad component name
- How To Test BOOT_COMPLETED Broadcast Receiver In Emulator
but the all came with the solution to run
./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED
or
./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c <CATEGORY> -n <PACKAGE_NAME>/<CLASS>
The first one restarts the device or the emulator but the debugger gets disconnected. The second one does not work. When I enter
./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME mypackage/.BootReceiver
the message is
Broadcasting: Intent { act=android.intent.action.BOOT_COMPLETED cat=[android.intent.category.HOME] cmp=mypackage/.BootReceiver }
Broadcast completed: result=0
and nothing happens. So my question is:
Is there a way to debug a BroadcastReceiver which gets triggered when android.intent.action.BOOT_COMPLETED
occurs?
I am using a Nexus 4 as a device and also a Nexus 4 as an emulator. My IDE is android studio with version 1.2.2.