【问题标题】:Get list of active PendingIntents in AlarmManager在 AlarmManager 中获取活动的 PendingIntents 列表
【发布时间】:2011-09-25 06:04:07
【问题描述】:

我有办法获取设备中活动PendingIntents 的列表吗?

我开始使用AlarmManager,我想看看我的PendingIntents 是否被正确创建和删除。

如果有什么其他的PendingIntents 也很高兴,就像好奇看看某个应用是否在做一些“额外的工作”。

【问题讨论】:

    标签: android android-pendingintent


    【解决方案1】:
    adb shell dumpsys alarm > dump.txt
    

    转储.txt:

    Current Alarm Manager state:
    
      Realtime wakeup (now=1309361618777):
      RTC_WAKEUP #5: Alarm{4822f618 type 0 com.google.android.gsf}
        type=0 when=1309882326582 repeatInterval=522747000 count=0
        operation=PendingIntent{47dd3740: PendingIntentRecord{4822aeb8 com.google.android.gsf broadcastIntent}}
      ...
      RTC #5: Alarm{4810f9d8 type 1 com.tmobile.selfhelp}
        type=1 when=1309445979715 repeatInterval=86400000 count=1
        operation=PendingIntent{4815a5c8: PendingIntentRecord{4810f960 com.tmobile.selfhelp startService}}
      RTC #4: Alarm{4810f668 type 1 com.tmobile.selfhelp}
        type=1 when=1309445959620 repeatInterval=86400000 count=1
        operation=PendingIntent{480996e8: PendingIntentRecord{480214a0 com.tmobile.selfhelp broadcastIntent}}
      ...
    
      Elapsed realtime wakeup (now=2110632):
      ELAPSED_WAKEUP #5: Alarm{481c24e0 type 2 com.google.android.apps.maps}
        type=2 when=2147485512925 repeatInterval=0 count=0
        operation=PendingIntent{47d1d3a8: PendingIntentRecord{481a2600 com.google.android.apps.maps broadcastIntent}}     
      ...
      ELAPSED #1: Alarm{4829ce98 type 3 android}
        type=3 when=2512653 repeatInterval=0 count=0
        operation=PendingIntent{47eabda8: PendingIntentRecord{47f20250 android broadcastIntent}}
      ELAPSED #0: Alarm{480f0198 type 3 com.mixzing.basic}
        type=3 when=2439998 repeatInterval=0 count=0
        operation=PendingIntent{48100dd8: PendingIntentRecord{480ff5a0 com.mixzing.basic broadcastIntent}}
    
      Broadcast ref count: 0
    
      Alarm Stats:
      com.google.android.location
        3ms running, 1 wakeups
        1 alarms: act=com.google.android.location.ALARM_WAKEUP flg=0x4
      com.google.android.gsf
        274ms running, 4 wakeups
        1 alarms: flg=0x4
        1 alarms: act=com.google.android.intent.action.GTALK_RECONNECT flg=0x4
        2 alarms: act=com.google.android.intent.action.GTALK_HEARTBEAT flg=0x4
     ...
    -------------------------------------------------------------------------------
    

    【讨论】:

    • 哦,原来有一个。尝试使用dumpsys alarm。我已经更新了答案。
    • 刚刚检查过,并且可以确认除非您有 root 权限,否则无法在设备上执行此操作“Permission Denial: can't dump AlarmManager from pid=16910, uid=10120”
    • count 属性代表什么?我的应用程序中有大量 type=3 when=+4m7s342ms repeatInterval=300000 count=4703 是否意味着设置了 4703 个警报?
    • @plastiv - 对于重复警报,count 测量应该触发多少次警报,但事实并非如此(即因为手机处于睡眠状态)。如果count > 1,则至少错过一次警报。所以repeatInterval=300000 count=4703 意味着闹钟应该每 5 分钟重复一次,但它错过了 4702 次——我猜手机关机了几天。
    • @koi-feeding - 我没有root,运行转储命令没有任何问题(运行摩托罗拉Moto G)
    【解决方案2】:

    adb shell dumpsys alarm > dump.txt 是要走的路,你不需要root权限。但是你从上面得到的东西可能很难理解。为了完全理解转储,您应该查看 morphatic 的答案here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      • 2013-10-06
      • 2022-11-05
      • 1970-01-01
      相关资源
      最近更新 更多