1

All the posts that are there on SO are using PendingIntent.getBroadcast(). Can we set multiple alarms with PendingIntent.getService()? I tried a code with PendingIntent.getService() for single alarm. It works fine. But I dont know how to set multiple alarms with PendingIntent.getService(). And using PendingIntent.Broadcast() s not issuing even a single alarms.

Experts plz help! :)

1 Answer 1

0

Can we set multiple alarms with PendingIntent.getService()?

Sure, so long as they are not using _WAKEUP alarms. The recipe for reliable _WAKEUP alarm requires a broadcast PendingIntent.

But I dont know how to set multiple alarms with PendingIntent.getService().

The same way you set up multiple alarms with any PendingIntent: call set(), setRepeating(), or setInexactRepeating() with a distinct PendingIntent. By "distinct" I mean that it has to differ in type (activity, service, or broadcast), or the Intent objects must not match on filterEquals(), or the request code used in the PendingIntent factory method (e.g., second parameter to getService()) must differ.

2
  • I'm using getBroadcast(), different Intent and different request code for the PendingIntent and still getting only one alarm firing off. Any idea why?
    – Dpedrinha
    Aug 30, 2017 at 1:29
  • @Dpedrinha: Use adb shell dumpsys alarm and confirm that you are actually scheduling more than one alarm. Beyond that, you would need to ask a separate question with a minimal reproducible example. Aug 30, 2017 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.