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
1
vote
1 answer

Cancel alarm and test if pending intent exist

I want to cancel alarm when this alarm exist fun isAlarmWorking(context: Context): Boolean { val intent = PendingIntent.getBroadcast( context.applicationContext, ALARM_ID, createAlarmReceiver(context.applicationContext), …
Mariusz
  • 1,352
  • 1
  • 16
  • 31
1
vote
4 answers

Periodically Updating my app's UI

I want my Android app to periodically update its UI based on the response from a REST service. I can't do this on the main thread because it's not permitted / bad practice to access the network on the main thread. The general wisdom on SO and the…
Douglas B. Staple
  • 10,510
  • 8
  • 31
  • 58
1
vote
1 answer

scheduling alarmmanager not working on reboot my phone

It's toasting until I didn't restart my phone but after restarting broadcastreceiver2 doesn't receive and nothing happens. I followed http://stacktips.com/tutorials/android/how-to-start-an-application-at-device-bootup-in-android and many other but…
1
vote
0 answers

Refresh date in Broadcast Receiver Android

I have a broadcast receiver class which I call at the beginning of a new day. Here is the broadcast receiver onReceive method. @Override public void onReceive(Context context, Intent intent) { context.sendBroadcast(new…
RJB
  • 1,704
  • 23
  • 50
1
vote
0 answers

AlarmManager cancel multiple events

i'm developing an application where i need to set multiple alarm in a day. Every time my application receives Intent.ACTION_DATE_CHANGE or Intent.ACTION_BOOT_COMPLETED i schedule schedule the alarms for the current day. Users from the application…
Marco Capoferri
  • 224
  • 2
  • 12
1
vote
1 answer

Android NotificationListenerService Background execution limit / Doze

With the introduction of Doze in Android M and Android getting more and more restrictive with background executions during Doze. Could someone elaborate if the same thing applies when extending Android's own services. For example…
1
vote
0 answers

Android studio set multiple alarms

I am trying to set multiple alarms in android studio. I set 2 arrays to save AlarmManager and PendingIntent with different request code. Once I click button It should save a new alarm and reset previous alarm. But I don't know why the only alarm…
Jay
  • 11
  • 1
1
vote
0 answers

After Reboot How I don"t get exception?

I am writing application for android.I have 2 activity layout.First one has customized listview that checkbox.User select listview items and click to button. And I set up 2 different alarm. First time user click to button on first activity"s layout…
1
vote
1 answer

Android repeating alarm not working for next days

i am trying to send notification everyday at some periods. its working for the day that i created the alarm. But the next days i am not getting any notification and my ReminderClass doesnt triggered. i googled it everywhere but couldnt solve the…
aligur
  • 3,387
  • 3
  • 34
  • 51
1
vote
0 answers

GPS is turning off when device is sleeping

I have built a tracking application which uses AlarmManager for periodic updates. I used a background service for this. The app is posting updates when the device is active and when it enters sleep mode, the GPS is automatically turning off and…
traj
  • 81
  • 2
  • 8
1
vote
1 answer

How to prevent my Samsung device from preventing my alarm application from working?

Android 6, 7 and 8 have a bug in the calendar provider that makes alarms not to work randomly: https://issuetracker.google.com/issues/64502046 So I developed my own calendar-based alarm application. But it doesn't work properly in my Samsung Galaxy…
user3289695
  • 740
  • 1
  • 9
  • 20
1
vote
0 answers

Multiple Alarms at Same Time

I have time let's say 01:01 am,now i want to trigger two notifications first is five minutes before the time and second is two minutes before the time. Here's the code I have done so far for this : fun setAlarm() { val time: String = "01:01…
1
vote
0 answers

Alarm Manager works fine in some devices and other doesn't work

Alarm Manager works fine in some devices (versions) and other (versions) doesn't work. it sometimes fires and some times doesn't . i make a lot of search but it still works fine in some devices (versions) and other (versions) doesn't work. here is…
1
vote
2 answers

Launching a specific Activity from an Alarm - even when application is closed

I'm looking to use AlarmManager to launch a specific activity (ie. not my main one) and cannot seem to figure out how to do it. I can launch the main activity (the one that opens when the application is launched normally) using the code found in…
1
vote
0 answers

IntentService scheduled by AlarmManager sometimes die

I have an app that every minute launches an IntentService that gets the UsageStats and UsageEvents on this period. I used setExact() method of AlarmManager to set the moment that the IntentService is executed and on the onCreate method of the…