Questions tagged [alarmmanager]

Android class providing access to the system alarm services.

AlarmManager class provides access to the system alarm services. These allow you to schedule your application to be run at some point in the future. When an alarm goes off, the Intent that had been registered for it is broadcast by the system, automatically starting the target application if it is not already running. Registered alarms are retained while the device is asleep (and can optionally wake the device up if they go off during that time), but will be cleared if it is turned off and rebooted.

The AlarmManager holds a CPU wake lock as long as the alarm receiver's onReceive() method is executing. This guarantees that the phone will not sleep until you have finished handling the broadcast. Once onReceive() returns, the AlarmManager releases this wake lock. This means that the phone will in some cases sleep as soon as your onReceive() method completes. If your alarm receiver called Context.startService(), it is possible that the phone will sleep before the requested service is launched. To prevent this, your BroadcastReceiver and Service will need to implement a separate wake lock policy to ensure that the phone continues running until the service becomes available.

AlarmManager reference

4606 questions
28
votes
4 answers

Android AlarmManager.setExactAndAllowWhileIdle() and WakefulBroadcastReceiver Not working in some new manufactured and low price devices

I think this question is asked many time in stackoverflow but still so many people struggling to resolved it. In my android app I have to wake up device for every half hour to getting current location and send it to server. For this I have used…
Himanshu
  • 861
  • 10
  • 25
27
votes
3 answers

How to detect if a notification has been dismissed?

Is there any way in Android to detect when a user swipes a notification to the left and deletes it? I'm using an alarmmanager to set a repeating alert and I need my repeating alert to stop when the notification is cancelled by the user. Here's my…
NewGradDev
  • 1,004
  • 6
  • 16
  • 35
26
votes
2 answers

How to get and cancel a PendingIntent?

I have an alarmManager which I am using to send notifications to the user at specific times. Since there are multiple alarms, I have multiple pending intents that I am creating and giving a unique ID, However there are certain situations in which I…
ninjasense
  • 13,756
  • 19
  • 75
  • 92
26
votes
2 answers

Cancel an AlarmManager pendingIntent in another pendingintent

I want cancel AlarmManager which define a service,in this service might start a new AlarmManger or cancel alarm that defined before.And I know the params pendingintent in alarmManager.cancel(PendingIntent),must be the same.compare with…
Albert.Qing
  • 4,220
  • 4
  • 37
  • 49
25
votes
4 answers

LocalNotification with AlarmManager and BroadcastReceiver not firing up in Android O (oreo)

I've got my local notifications running on androids prior to SDK 26 But in a Android O I've got the following warning, and the broadcast receiver is not fired. W/BroadcastQueue: Background execution not allowed: receiving Intent {…
Hug
  • 589
  • 2
  • 6
  • 16
25
votes
3 answers

How can I correctly pass unique extras to a pending intent?

I'm having a problem with alarmManager and the pending intent with extras that will go along with it. If I set multiple alarms, they will go off, however the extras stay the same. I have already read into these questions: android pending intent…
ninjasense
  • 13,756
  • 19
  • 75
  • 92
25
votes
4 answers

AlarmManager not working

I need to start the activity AlarmReceiver after 10 seconds (for example). I need it to be activated without running the app. But whether the app runs or not the AlarmReceiver do not get called. Any suggestions? Intent intent = new Intent(this,…
dinesh707
  • 12,106
  • 22
  • 84
  • 134
24
votes
2 answers

How does android compare pending intents

Documentation for PendingIntent.FLAG_NO_CREATE reads: Flag indicating that if the described PendingIntent does not already exist, then simply return null instead of creating it. My question: What criteria are used to compare PendingIntents? I'm…
Steven Wexler
  • 16,589
  • 8
  • 53
  • 80
24
votes
2 answers

Is it possible to create multiple PendingIntents with the same requestCode and different extras?

I'm using AlarmManager to schedule anywhere between 1 and 35 alarms (depending on user input). When the user requests to schedule new alarms, I need to cancel the current alarms, so I create all of my alarms with the same requestCode, defined in a…
Snailer
  • 3,777
  • 3
  • 35
  • 46
23
votes
5 answers

How to create different pendingintent so filterEquals() return false?

I'm using AlarmManager to set up repeating intents but it has caused some little troubles so hope anyone could help. Summary There are 2 pending intents. One runs at 1000 and another runs at 2000 every day. Each contains a row id from the database…
markbse
  • 1,023
  • 3
  • 13
  • 26
23
votes
5 answers

Android 12: Using SCHEDULE_EXACT_ALARM permission to get/show data at specific time are safe in Google Play Policy?

I have an Android app on Play store for 8 years. Recently Google release Android S or 12 introduce some limit with Foreground service launch…
DzungPV
  • 1,561
  • 3
  • 18
  • 24
23
votes
2 answers

How to save scheduled alarm after app was killed by Android or task killer?

Code that schedules alarm. PendingIntent sender = PendingIntent.getBroadcast(this, id, intent, PendingIntent.FLAG_UPDATE_CURRENT); AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); am.set(AlarmManager.RTC_WAKEUP, time,…
Divers
  • 9,531
  • 7
  • 45
  • 88
22
votes
1 answer

Identify and cancel an alarm send to an AlarmManager

If I use the AlarmManager to schedule an alarm (a PendintIntent which should be send), how can I identify that alarm later to cancel it? Can I cancel all alarms scheduled by my app?
cody
  • 6,389
  • 15
  • 52
  • 77
22
votes
7 answers

setRepeating() of AlarmManager repeats after 1 minute no matter what the time is set (5 seconds in this case, API 18+)

I have set the repeat time to 5 seconds. The first toast appears after 5 seconds, but all the next once repeat after 1 minute. I tried the code with setRepeating() as well, it still doesn't work. here is my code: public void constructJob(){ …
Nikhil Tambe
  • 502
  • 1
  • 4
  • 13
21
votes
5 answers

How to run activity in background in Android

In my application, I need to send the text message to the user after a certain interval. For that I need to run the message sending code in background. I am using the alarm manager to start activity at specific time.What to do? Is there another way…
picaso
  • 713
  • 2
  • 14
  • 26