Debug android.intent.action.BOOT_COMPLETED

I want to debug BroadcastReceiver

which should fire my onReceive method when an activity fires android.intent.action.BOOT_COMPLETED

. I have read several sources such as

but all came with a 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 restarts the device or emulator, but the debugger is disabled. The second one doesn't work. When i enter

./adb shell am broadcast -a android.intent.action.BOOT_COMPLETED -c android.intent.category.HOME mypackage/.BootReceiver

      

message

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 the BroadcastReceiver that gets triggered when it is encountered android.intent.action.BOOT_COMPLETED

?

I am using Nexus 4 as my device and also Nexus 4 as my emulator. My IDE is android studio with version 1.2.2.

+3


source to share


1 answer


Use sendBroadcast () to send broadcasts manually

Add any action ("NameofAction") to the receiver in the manifest and then manually use sendBroadcast (new Intent ("NameofAction")) with the name given in the receiver element in the manifest.



and onReceive () check the action ("NameofAction").

+1


source







All Articles