如何查看Android系统当前发送了什么广播

Posted 邱小琪Yogi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何查看Android系统当前发送了什么广播相关的知识,希望对你有一定的参考价值。

作者:Yogi

前言:在开发的时候,我们有时想知道我们定义的广播是否成功发送,或者想知道做了某个操作,系统是否会发送广播,并且发送了什么广播。如果说能够直接查看到,那是非常好的,这样就不需要google,百度,也不需要深入底层看源码。此篇文章就是告诉你这个调试的小技巧,非常实用哦。

查看android系统广播发送记录

这条命令是

dumpsys |grep BroadcastRecord

敲入这条命令,我的机顶盒打印是

BroadcastRecord2cfa0820 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cd10530 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf94b18 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf71bd0 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfbe378 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cea3b30 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2ce8f548 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf1dea0 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfa5f38 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cefa680 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf16a20 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2ce53d38 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cea8588 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cede788 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf30000 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf40f08 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf7dd60 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfb9e10 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfbeab0 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfc1088 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfc1ee8 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfc36d8 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfcb678 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2ceed3a0 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cdde158 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf718a8 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf1f2c8 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfe8fe8 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2ce8ea70 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cff0d90 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf16418 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf7a950 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cec99c0 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2ced7810 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf07960 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf73440 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cef4538 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cfa6570 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cee0430 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf9a940 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf1bd88 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf47260 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cff34a8 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cdc5e78 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cce3398 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cee7538 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2ced4a40 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cd1f978 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cdc5678 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf397e0 u-1 android.intent.action.TIME_TICK to user -1
BroadcastRecord2cf76040 u-1 test to user -1
BroadcastRecord2cf43088 u-1 test to user -1
BroadcastRecord2cf46930 u-1 test to user -1
BroadcastRecord2cfabf00 u0 android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED to user 0
BroadcastRecord2cf73338 u0 com.android.server.action.NETWORK_STATS_POLL to user 0
BroadcastRecord2cf717a0 u-1 com.android.server.action.NETWORK_STATS_UPDATED to user -1
BroadcastRecord2cf7c718 u0 android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED to user 0
BroadcastRecord2cf85d18 u0 android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED to user 0
BroadcastRecord2cf1d428 u0 com.android.server.action.NETWORK_STATS_POLL to user 0
BroadcastRecord2cff5048 u-1 com.android.server.action.NETWORK_STATS_UPDATED to user -1
BroadcastRecord2cff4e38 u0 android.net.ConnectivityService.action.PKT_CNT_SAMPLE_INTERVAL_ELAPSED to user 0
BroadcastRecord2cfcbd30 u0 RUN_TV_PAYER_OFF to user 0
BroadcastRecord2cfa6960 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfa4aa8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf26c88 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf7a5c8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfcb4b0 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfb78f8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfbd2a0 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cd14ca0 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf70c38 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfc6728 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf735d0 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfa8288 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf29b98 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf77f88 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf6d398 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf7c290 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf402f8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfcef20 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2ce89ef0 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf47b60 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf02608 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf71618 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfba098 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf181f8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2ce986c8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf2a200 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cdc5da8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cee35b8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2ce989b0 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cee42f8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cfb7690 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cee3010 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2ce4db28 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2ceb3570 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cefd0b8 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2ce97800 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf18b88 u-1 android.media.VOLUME_CHANGED_ACTION to user -1
BroadcastRecord2cf47488 u-1 android.media.VOLUME_CHANGED_ACTION to user -1

从上到下,是按照从新到旧的顺序排列的,也就是说第一行是系统最新发出的一个广播。

dumpsys

这个命令能够打印出系统近期的运行状况,可以找到很多有用的信息。

总结

当你需要系统信息时,可以用dumpsys命令查看系统状态,并在里面找出需要的信息,当只需要查看系统发送过哪些广播时,则用dumpsys |grep BroadcastRecord

以上是关于如何查看Android系统当前发送了什么广播的主要内容,如果未能解决你的问题,请参考以下文章

Broadcast Server

android app中的服务为啥接收不到广播

Android BroadcastReceiver

Android开发之广播

Android广播阻塞、延迟问题

BroadcastReceiver