89

I there a way to get a list of the active PendingIntents in a device?

I am starting to work with AlarmManager and I like to see if my PendingIntents are created and removed correctly.

It would also be nice to see what other PendingIntents are there, just as a curiosity to see if some app is doing some "extra work".

BrainCrash
  • 12,992
  • 3
  • 32
  • 38

3 Answers3

181
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
 ...
-------------------------------------------------------------------------------
janot
  • 13,578
  • 1
  • 27
  • 57
inazaruk
  • 74,247
  • 24
  • 188
  • 156
  • 1
    Oh, it turns out there is one. Try using `dumpsys alarm`. I've updated the answer. – inazaruk Jun 29 '11 at 18:50
  • 2
    Just checked, and can confirm it's not possible to to do this on-device unless you have root "Permission Denial: can't dump AlarmManager from pid=16910, uid=10120" – koi-feeding Sep 11 '12 at 10:44
  • 1
    What _count_ property stands for? I have big amount in my app `type=3 when=+4m7s342ms repeatInterval=300000 count=4703` Does it mean 4703 alarms was setup? – Sergii Pechenizkyi Feb 01 '13 at 16:29
  • 1
    @plastiv - for repeating alarms, `count` measures how many times alarm should've been triggered, but it wasn't (i.e. because the phone was sleeping). If `count > 1`, alarm was missed at least once. So `repeatInterval=300000 count=4703` means alarm is supposed to repeat once every 5 minutes, but it missed it 4702 times - I guess phone was powered off for a couple of days. – kamituel Nov 17 '13 at 22:48
  • 1
    @koi-feeding - I'm not rooted and I didn't have any problems running the dump command (running a Motorola Moto G) – RTF Jan 24 '14 at 12:50
  • this should be possible to do programmatically, FFS. – Someone Somewhere Aug 03 '15 at 18:30
  • I get this at the end 25 wakes 25 alarms, does it mean I have 25 alarms running on my app? Or that it has waken 25 times? – Jesus Almaral - Hackaprende Nov 01 '17 at 21:47
  • 1
    I checked, is the times it has waken up – Jesus Almaral - Hackaprende Nov 01 '17 at 21:58
  • I recommend combinding this with `grep` if you are only interested in the alarms of your app: `adb shell dumpsys alarm | grep your.app.id` - I'm not putting this into an extra answer as the OP specifically wanted to know about other apps' alarms as well. – ubuntudroid Mar 12 '20 at 16:20
5

adb shell dumpsys alarm > dump.txt is the way to go and you don't need root permission for that. But what you get from above could be very confusing to understand. In order to understand that dump completely you should check out morphatic's answer here.

Community
  • 1
  • 1
Uncaught Exception
  • 2,149
  • 18
  • 25
0

First Install "adb" as command

1- print

echo $path 

2- open editor

vim /etc/paths

3- to make “insert” mode Click on “I”

4- copy/past the environment variable example:

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

5- Press ""Esc"" then write + write colon”:” it will navigate to last line of editor

6- write “wq” + click enter

7- close terminal and open again, test print

echo $path

Case when save print error "E212" see

bug: vim when save print "/etc/paths" E212:

Second: Run Emulator :

1- set path of emulator path of sdk

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

(Save in paths, then restart terminal )

2- to run specific emulator format emulator -avd avd_name

Example:

emulator -avd Pixel_4_API_28

How To Print Pending Intent

termnial write to see all Pending Intent :

adb shell dumpsys alarm
Abdallah Mahmoud
  • 491
  • 1
  • 5
  • 8