How to check if AlarmManager already has an alarm set?
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.
Introduction
AlarmManager does not provide a direct "is this alarm scheduled" query. The usual way to check is to ask Android whether the matching PendingIntent already exists. If it does, you can treat that as evidence that the alarm has been scheduled with that same identity.
The Key Idea: Match the PendingIntent
When you schedule an alarm, you normally pass a PendingIntent created with:
- the same target component
- the same request code
- the same intent action, data, type, class, and categories
To check whether it already exists, recreate that PendingIntent with FLAG_NO_CREATE. Android returns the existing object if one matches, otherwise it returns null.
That is the standard pattern.
Why Matching Matters So Much
The check only works if the identity matches exactly. If you change the request code or use getService instead of getBroadcast, Android treats it as a different PendingIntent.
In practice, this means your "is alarm set" logic must reuse the same construction rules as the scheduling code:
If the scheduling code and checking code drift apart, the check becomes unreliable.
Important Detail About Extras
A common trap is assuming extras uniquely identify the PendingIntent. They do not. Extras are not the main identity components used for matching. That is why request code and core intent fields matter more than an extra bundle attached to the intent.
So if you schedule alarms for different records, the safest pattern is often to vary the request code or the intent data URI, not only extras.
Use App State When You Need More Than Presence
This technique answers "does a matching PendingIntent exist." It does not tell you:
- the exact trigger time still registered
- whether the system later deferred delivery
- whether your app logic still considers the alarm valid
If you need stronger guarantees, store alarm metadata in your own persistence layer as well. Many apps keep the intended trigger timestamp in shared preferences or a database and use PendingIntent existence as a secondary check. That extra record is especially useful after app restarts or reminder edits.
Cancel and Replace Predictably
When updating alarms, reuse the same identity and cancel before replacing if needed:
Predictable identity management makes both scheduling and checking much easier.
Common Pitfalls
- Expecting
AlarmManagerto expose a direct query API for scheduled alarms. - Recreating the
PendingIntentwith a different request code or target and then trusting the result. - Assuming intent extras are enough to distinguish alarms.
- Using a different factory method such as
getServicewhen the alarm was created withgetBroadcast. - Treating
PendingIntentexistence as complete proof of timing state instead of only identity presence.
Summary
- There is no direct
AlarmManagermethod to ask whether an alarm already exists. - The normal solution is to recreate the same
PendingIntentwithFLAG_NO_CREATE. - Matching depends on request code and core intent identity, not only extras.
- Keep scheduling and checking logic aligned so the identity stays stable.
- Store your own alarm metadata if you also need exact business-state tracking.
Related reading
- How to check if all elements of a list match a condition?
- How to check if an element is in an array
- How to check if object is an array of a certain type?
- How to check if one of the following items is in a list?
- How to check if Receiver is registered in Android?
- How to check if the user gave permission to use the camera?
- How to check if PHP array is associative or sequential?
- How to check node name of tensorflow graph protocol buffers by c

DSA Fundamentals
Master algorithmic patterns and data structures through hands-on LeetCode-style problems - from arrays and hashing to dynamic programming and advanced graphs.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Data Structures & Algorithms practice on Codemia
Step through 300 algorithm problems with animated visualisers that show the data structure changing as the code runs.