jjzjj

android - 亚行外壳 : How do I get a list of BroadcastReceivers that will receive BOOT_COMPLETED Intent?

coder 2023-12-01 原文

我目前正在调试一个应在设备启动后自动启动的应用程序。为此,我创建了一个 BroadcastReceiver 并将其添加到我的 AndroidManifest.xml 中:

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

这在大多数设备上始终有效。然而,在一台设备(MXQ Pro 机顶盒)上,它只能在大部分时间工作。到目前为止,我还没有找到它何时有效和何时无效的任何模式。

所以,我想知道实际上有哪些 BroadcastReceivers 当前已在系统中注册以接收 BOOT_COMPLETED Intent。

我玩了一下

  • pm:但这只会告诉我哪些包想要接收 Intent
  • dumpsys:但是它的输出太多了,我不知道要找什么

感谢您的任何建议!

最佳答案

如果您只需要确认某些特定的 receiver 已正确注册(即您只关心某个您知道名称的特定包中的 receiver),那么只需使用 dumpsys package my.package .name 就像评论中建议的 @pskink 一样。

但如果您确实想知道系统范围内的所有接收器都接收了一些特定的intent - 从 Android 7.0 开始您可以使用

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

如果您需要更多详细信息,请删除 --brief 参数。并仅列出名称:

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

关于android - 亚行外壳 : How do I get a list of BroadcastReceivers that will receive BOOT_COMPLETED Intent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37746459/

有关android - 亚行外壳 : How do I get a list of BroadcastReceivers that will receive BOOT_COMPLETED Intent?的更多相关文章

随机推荐