android 获取AlarmManager中活动PendingIntents的列表

bfhwhh0e  于 2023-03-11  发布在  Android
关注(0)|答案(3)|浏览(102)

是否有办法获得设备中活动PendingIntent的列表?
我开始使用AlarmManager,我想看看我的PendingIntent是否被正确地创建和删除。
如果能看看还有什么其他的PendingIntent s也会很好,只是作为一种好奇心,看看是否有某个应用程序在做一些“额外的工作”。

3xiyfsfu

3xiyfsfu1#

adb shell dumpsys alarm > dump.txt

dump.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
 ...
-------------------------------------------------------------------------------
lyr7nygr

lyr7nygr2#

adb shell dumpsys alarm〉dump.txt是一个不错的方法,你不需要root权限就可以使用它.但是你从上面得到的东西可能会让你很难理解.为了完全理解这个转储文件,你应该看看morphatic的答案here .

wlwcrazw

wlwcrazw3#

首先将“adb”安装为命令

1-列印

echo $path

2-打开编辑器

vim /etc/paths

3-进入“插入”模式点击“I”
4-复制/粘贴环境变量示例:

/Users/abdallahandroid/Library/Android/sdk/platform-tools
/Users/abdallahandroid/Library/Android/sdk/platform-tools/adb
/Users/abdallahandroid/Library/Android/sdk/emulator

5-按“Esc”,然后写入+写入冒号”:“,将导航到编辑器的最后一行
6-写入“wq”+点击回车
7-关闭终端并再次打开,测试打印

echo $path

保存打印错误“E212”时的情况,参见

错误:保存打印“/etc/paths”E212时的vim:

秒:运行模拟器:

1-设置sdk的仿真器路径

/Users/abdallahandroid/Library/Android/sdk/emulator

(Save在路径中,然后重新启动终端)
2-运行特定的模拟器格式emulator -avd avd_name
示例:

emulator -avd Pixel_4_API_28

如何打印待定意向

最终写入以查看所有挂起意向:

adb shell dumpsys alarm

相关问题