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
13
votes
7 answers

scheduling alarm for every second in android 5.1

I want to run alarm service for every second in my application.It is working fine below 5.1 version. but it is not triggering in 5.1 devices. I am using commonsware wakeful intent service.The logcat message is saying that "Suspiciously short…
Chaitu
  • 907
  • 2
  • 13
  • 27
13
votes
2 answers

Android Alarm manager working, but delayed

I would like to make a delay(10 min) for user then after it, user can edit something. to do this,I created a setAlarm function : public void setAlarm(Context context,int user,int time) { AlarmManager am = (AlarmManager)…
S.M_Emamian
  • 17,005
  • 37
  • 135
  • 254
13
votes
1 answer

AlarmManager: how to schedule a daily alarm and deal with time changes

I need to set up an alarm daily at a given hour. I'm programming the alarm using AlarmManager.RTC_WAKEUP, so it uses the system time as reference. I'm setting the alarm to first execute at the desired hour, then to repeat daily: …
Mister Smith
  • 27,417
  • 21
  • 110
  • 193
12
votes
3 answers

How to keep a TCP connection established indefinitely?

I need to keep a TCP connection established indefinitely (as far as possible). Is not an own server so we cannot change the way it works. This server needs some kind on ping each minute to know that the connection is alive. If the server do not…
Alvaro Luis Bustamante
  • 8,157
  • 3
  • 28
  • 42
12
votes
2 answers

One-time permissions causing background scheduled jobs and alarms to be cancelled

We develop an Android SDK and, while testing the Android 11 Beta, we found a problem that does not seem to be reported yet. In Android 11, new one-time permissions have been introduced for Location, Microphone and Camera permissions. With this…
12
votes
0 answers

IllegalStateException AlarmManager Maximum limit of concurrent alarms 500 reached on Android 10

Using alarms with pending broadcasts, this was working as intended until recently a crash started appearing for RealMe devices running on Android 10 and few OPPO devices running on Android 7.1.1 Crash : IllegalStateException: Maximum limit of…
rd7773
  • 409
  • 3
  • 13
12
votes
1 answer

Why Alarm icon is not shown ONLY on Samsung Android 9 devices when set with AlarmManager.setAlarmClock()?

I use AlarmManager.setAlarmClock() to set an alarm. Alarm is fired on all devices, including Samsung, but the small alarm icon near the clock (top right corner of the screen) is missing on Samsung devices with Android 9. What am I missing here? I…
12
votes
3 answers

Android alarm not working

I've been struggling with this for hours. I've also checked the documentation and several topics. I found this code in two topics, both guys said the code was working perfectly, but not on my computer. The first Toast appears, but the second one…
erdomester
  • 11,789
  • 32
  • 132
  • 234
12
votes
2 answers

Alarm Manager not firing when app is killed on Android 7 (One Plus 3T)

Since the introduction Doze Mode and App StandBy managing alarms have changed. The problem I'm facing is my alarm manager fires correctly on KitKat, Lolipop and Marshmellow devices but above API 23 it does not fire unless the app is in foreground or…
Veeresh Charantimath
  • 4,641
  • 5
  • 27
  • 36
12
votes
3 answers

How to schedule my android app to do something every hour

I want my app to access database every hour and read next record from the table then update desctop widget and send notification. I know that there is AlarmManager which I can use to register my Intents but they are deleted when the phone is turned…
Marqs
  • 17,800
  • 4
  • 30
  • 40
12
votes
1 answer

android prevent immediate trigger of alarm service if alarm time has passed for the day

The reference for Alarm Manager says that If the stated trigger time is in the past, the alarm will be triggered immediately. I am facing this problem in my application. Here is my alarm manager code : Intent myIntent = new…
Flame of udun
  • 2,136
  • 7
  • 35
  • 79
12
votes
2 answers

Unable to check if alarm has been set by AlarmManager

I am checking if the alarm has already been set by the AlarmManager using this answer. Following is my code snippet. boolean alarmUp = (PendingIntent.getBroadcast(MainActivity.this, 0, new Intent(MainActivity.this, AlarmReceiver.class),…
Kevin Richards
  • 570
  • 1
  • 6
  • 23
12
votes
2 answers

Android - How to set a notification to a specific date in the future?

Edit: SOLVED! Ever wanted to set a notification from a specific date starting a certain point in time (when an activity is started or when a button is pressed?) Read more to find out how: //Set a notification in 7 days Calendar…
eddielement
  • 143
  • 1
  • 1
  • 6
12
votes
2 answers

Do Android AlarmManagers continue to run after an app update?

From what I can see, if you schedule an indefinitely repeating alarm it won't stop running until you reboot your device or uninstall the app. I was wondering, how do these behave in the event of an app update? i.e. you download version 1 of the app…
brent777
  • 3,369
  • 1
  • 26
  • 35
12
votes
2 answers

Set alarm from Android 4.4 Kitkat

In Android 4.4 APIs page I read: When you set your app's targetSdkVersion to "19" or higher, alarms that you create using either set() or setRepeating() will be inexact. [CUT] This inexact batching behavior applies only to updated apps. If…
crbin1
  • 2,219
  • 3
  • 22
  • 29