ADB shell: How do I get a list of BroadcastReceivers that will receive BOOT_COMPLETED Intent?
Asked Answered
U

1

14

I am currently debugging an application that should auto-start after the device boots. To this end I have created a BroadcastReceiver and added it to my AndroidManifest.xml:

<receiver android:name=".receiver.StartupBroadcastReceiver">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
    </intent-filter>
</receiver>

This works all of the time on most devices. On one device however (an MXQ Pro set-top box) it only works most of the time. So far, I have not been able to find any patterns in when it works and when it does not.

So, I would like to find out which BroadcastReceivers are actually, currently registered with the system to receive the BOOT_COMPLETED Intent.

I played around a bit with

  • pm: but this only tells me which packages would like to receive the Intent
  • dumpsys: but its output is overwhelming and I don't know what to look for

Thanks for any advice!

Underbrush answered 10/6, 2016 at 10:54 Comment(3)
tried dumpsys activity -h?Urnfield
Ah, yes, I did look at the documentation. dumpsys activity b seemed promising, but I can find neither my package name nor the actual BroadcastReceiver in there, even on devices where everything works. There are hundreds of "ReceiverLists" each with their own ID, but nothing matches the output of, for example, dumpsys package my.package.name either. Hence the "overwhelming".Underbrush
i just run dumpsys package my.package.name and got: Receiver Resolver Table: Non-Data Actions: android.intent.action.BOOT_COMPLETED: 52b3eee0 my.package.name/.MyReceiver filter 52b3ef68 Action: "android.intent.action.BOOT_COMPLETED"Urnfield
L
25

If you just need to confirm that some specific receiver was properly registered (i.e. you care only about receivers in some specific package you know name of) then just use dumpsys package my.package.name like @pskink suggested in the comments.

But if you indeed want to know all the receivers system-wide receiving some specific intent - since Android 7.0 you can use

adb shell cmd package query-receivers --brief -a android.intent.action.BOOT_COMPLETED

Remove the --brief parameter if you want more details. And to list just the names:

adb shell cmd package query-receivers --components -a android.intent.action.BOOT_COMPLETED
Lam answered 10/7, 2017 at 17:29 Comment(2)
Is there also a way to get all receivers at once, not only the BOOT_COMPLETED ones.Forbiddance
@Alex P. How to check receiver without ACTION(explicit) is registered or not?Miserly

© 2022 - 2024 — McMap. All rights reserved.