Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 943
david.mihola Avatar asked Jun 10 '16 10:06

david.mihola


1 Answers

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
like image 156
Alex P. Avatar answered Sep 28 '22 05:09

Alex P.