FAQ Database Discussion Community


Delete specific ALARM from AlarmManger in Android

android,alarmmanager
I am building a reminder app using alarmManger but I don't know how to delete a specific alarm. AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 10); calendar.set(Calendar.MINUTE, 30); Intent intent = new Intent(MainActivity.this, AlarmReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);...

Delete a pending alarm / notification from service

android,notifications,alarmmanager,android-alarms
I have an activity that calls a Helper, where I create a notification what will pop-up in a selected time. It works great. I want to create another function in a different activity that can delete a pending alarm before the notification pops up. I tried many ways I found...

Adding notification using alarm in android

android,push-notification,alarmmanager
I have two activities. In the first activity, I have set alarm. Now, I want to trigger after 5 seconds and start the second activity. The second activity pushes the notification. For the purpose, I wrote the following code: Adding alarm Class : public class NotificationClass extends ActionBarActivity { AlarmManager...

periodically send location updates using fusedLocation API

android,location,alarmmanager,periodic-task,fusedlocationproviderapi
Android programming is a brand new thing to me, i've been playing with android's location and i have a same issue, im going to send a periodic location updates to a server in background and i'm using the AlarmManager/LocationManager approach, set an alarmManager with a defined Interval then when the...

How do I set notification in android application at specific time?

android,android-intent,android-activity,alarmmanager,android-alarms
I have used following code in android application to set up Notification(Alarm) using AlarmManager. public void setAlarm() { Intent intent = new Intent(MainActivity.this, TimeAlarm.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); am.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), (40000), pendingIntent); } Or should I use following code Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.MONTH, 3); calendar.set(Calendar.YEAR, 2015);...

AlarmManager not going off at correct time

java,android,alarmmanager,timepicker
I am creating an app that uses a TimePicker that the user sets a time that they want an SMS sent to a specified number. They also have the option to click repeat so that the SMS will continue to be sent at that same specified time every day. My...

WakefulBroadcastReceiver doesn't receive PendingIntent from AlarmManager

android,broadcastreceiver,alarmmanager,android-pendingintent,android-alarms
I'm struggling on an app that must repeat a task with a specified interval. I want it to wakeup the device if needed. I have no idea why, but the WakefulBroadcastReceiver NEVER executes its onReceive method that should be triggered via AlarmManager. The problem persists with a normal BroadcastReceiver. I'm...

What is the difference between scheduling same task using alarm manager vs ScheduledExecutorService

android,alarmmanager,scheduledexecutorservice
Hi I was reading on internet that we can schedule any thing which we want to run at a gap of certain interval using alarm manager and ScheduledExecutorService. I want to know what is the difference between them and what to use when Thanks in advance....

AlarmManager or CalendarProvider, What should be used for an app like Keep or Evernote?

android,alarmmanager,android-alarms,android-calendar,repeatingalarm
I am developing an android application just like Google Keep and Evernote. Now I want to add many reminders or alarms one time and repeated too. I have both options and I am confused.

How to set a reliable long-term alarm in Android?

android,cordova,phonegap-plugins,alarmmanager,android-alarms
I'm developing an Android app with Phonegap. I need to set a long-term alarm to remind users things like a monthly task. I was searching plugins for this, but the most popular plugin that I found it doesn't have enough reliability. I've tried to use it, but it only works...

Inquiry related to AlarmManager and WakeLocks

android,alarmmanager,wakelock,android-wake-lock,repeatingalarm
I am developing a native android app that run a backup operation every 30 mins. I am using AlarmManager for this purpose and it works fine. Here is the code I am using to start the alarm: public static void startSync(Context context) { alarmIntent = new Intent(context, AlarmReceiver.class); pendingIntent =...

Background app without Gui, starts periodically every hour Android

android,broadcastreceiver,alarmmanager,background-service
I am making an application which will check for files on storage directory and then utilize the files and upload to ssh server. I was thinking about making a BroadcastReceiver which will start background Service on system boot, the Service will update AlarmManager which will start every hour/every day a...

AlarmManager.setExact is not waiting the time interval

android,broadcastreceiver,alarmmanager
I have the following line alarm.setExact(AlarmManager.RTC_WAKEUP,10000,pintent); from what I understand I should receive a call from the AlarmManager to my Broadcast Receiver's onReceive after 10 seconds. How ever my Logs show that it reaches the onReceive method immediately. Is this normal? what method is triggered after the time specified in...

When my app is closed Strings are returning null in a class extending BroadcastReceiver when references static methods in another class

java,android,static,broadcastreceiver,alarmmanager
I am creating an app that has an sms sending feature. I am currently having an issue that involves the an AlarmManager (which is functioning properly) that calls a class that extends BroadcastReceiver. The class using the AlarmManager is MainMenu.class and the class extending BroadcastReceiver is AlarmReceiver.class. Inside the MainMenu...

Android notification stays open when launching app

android,android-intent,alarmmanager,android-notifications,android-pendingintent
I'm able to queue and launch notifications through AlarmManager, I'm also able to launch my application when clicking the notification. Unfortunately the notification isn't removing itself when the application is launched. Notification setup: Intent intent = new Intent(mainActivity, NotificationPublisher.class); intent.setAction("handle"); PendingIntent pIntent = PendingIntent.getBroadcast(mainActivity, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Notification.Builder builder =...

Application is opening on notification creation using Alarm Manager

android,alarmmanager,android-notifications
Here is what I am trying to do : I am trying to trigger a notification everyday at a specific time which the user can select in settings screen. The issue I am currently facing is, whenever the alarm triggers and displays the notification, the application opens and closes. Please...

Lollipop API for controlling the Alarm icon in status bar

android,alarmmanager,alarm,android-alarms,undocumented-behavior
This is a Lollipop-specific question, since the API has changed. To find out how to do this on earlier versions, see related question: Controlling the Alarm icon in status bar I would like to know how to turn on / off the system Alarm icon in the status bar as...

Android set session expired to all activities at once

android,session,alarmmanager,session-timeout,android-alarms
I have a method that checks if the user has internet connection, and if he doesn't he has 24h to get online again, if not the app should stop and take the user to the login activity, it is working, but the problem is, I'm calling this method in the...

How do I configure my AlarmReceiver to actually trigger at my desired interval?

android,android-intent,alarmmanager,android-alarms,repeatingalarm
The goal for this portion of my app is to run a repeating alarm in the background at all times that grabs a new prediction every 15 minutes from a server side machine learning algorithm, updating the app. I currently have the skeleton for this desired behavior implemented, to make...

How to measure battery usage for specific alarm manager?

android,alarmmanager,battery
I have an alarm manager and I check with my server every 30 minutes for new data, i want to measure battery usage of this specific task or another question how to measure battery usage of running each service and class in my application?

AlarmManager not firing when requested

android,alarmmanager
So I've made an app that's supposed to send a notification at 8:15 every Wednesday morning. I'm using an AlarmManager to send inexact repeating alarms from a calendar date to open a pending intent that sends a notification. What's currently happening is the notification is being sent only if you...

Android: why are old PendingIntents not deleted unless I reboot or manually uninstall the app?

android,android-intent,android-studio,alarmmanager,android-pendingintent
Some background I have an app that has an ongoing notification. I use NotificationCompat.Builder to create the notification. I call setContentIntent() on the builder to add a PendingIntent to the notification, so that MyActivity runs when I click on the notification. When MyActivity is running, and I click on the...

AlarmManager with flag AlarmManager.INTERVAL_DAY is executing in the current day, not in the next day

android,push-notification,alarmmanager,android-alarms
I need to add push notifications in my Android application. The notification must be shown every day at certain time (for example at 1 PM). To do this i am using an AlarmManager. I am registering an alarm, when the app is starting for the first time. But i got...

Android notification app not working properly

java,android,notifications,alarmmanager,android-notifications
I'm developing an android app, and part of it involves a notification that reminds the user to do something. This notification at a specified time and repeats every 12 hours. I'm using AlarmManager to schedule the alarm and I've also included the code to start my Alarm Service when the...

How to terminate invoking setAlarm once the alarm is rang.

java,android,service,alarmmanager
My Problem : setAlarms() method is called again and again (64 times a second!!) by the service once alarm starts ringing. How can I stop calling it once the alarm starts ringing? My code TRTimeReminder.class This is the class where a new alarm can be set. TRAlarmManager.cancelAlarms(this); //cancel the the...

Can't set AlarmManager to repeting one

android,service,alarmmanager,android-5.0-lollipop
I'm trying to set an Alarm to wakes up every 30s but it doesn't work. It does just 1 time at the beggining. I'm not sure if i've to use setInexactRepeating or setRepeating or setExact(and recall the method); and if i should use ELAPSED_REALTIME_WAKEUP or RTC_WAKEUP. public void onClick(View view)...

Scheduling repeating alarms

android,alarmmanager,android-alarms
I'm scheduling repeating alarms in order to execute service one a period of time. // Set the alarm to start at approximately 24:05 a.m. Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(System.currentTimeMillis()); calendar.set(Calendar.HOUR_OF_DAY, 24); calendar.set(Calendar.MINUTE, 5); alarmMgr.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), AlarmManager.INTERVAL_DAY, ); Some question about the implementation : What happens if user delete the application...

Having trouble registering an alarm with AlarmManager at boot

android,alarmmanager
When a device shuts off, all alarms registered with AlarmManager are wiped out. I am attempting to reschedule my alarm with AlarmManger on boot. Here is my BroadcastReceiver: public class DeviceBootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Toast.makeText(context, "DeviceBootReceiver::onReceive", Toast.LENGTH_LONG).show(); if (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")) { Toast.makeText(context,"boot alarm",Toast.LENGTH_LONG).show();...

AlarmManager fires twice in Android Version 4.4.2 KitKat

android,alarmmanager
I have an alarmManager that fires one time in all Android Versions, but only in Version 4.4.2 it fires twice. I read that there were changes in this version that affected AlarmManager, but I don't know how to workaround it, and if this is the case here... Any suggestions? This...

Android: How to send an sms after an alarm ?

android,alarmmanager,smsmanager
my question is about an how to rather than a question of coding problem. I am tryn to send an sms after a certain amount of time if the activity is not closed. To explain it more, for example we have an app. To begin with in this app user...

Alarm Manager not triggering on time when app is closed

android,notifications,alarmmanager
I want to set an alarm at 9am that will execute only once in a day and with this alarm i want to execute one BroadcastReciver and through that BroadcastReciver i want to execute Service. I am Using the following code but in this code following are problems 1)Alarm is...

Running Frequently task using AlarmManager

alarmmanager,android-alarms
I want to run some task in background without telling user, to send some data to server. Requirement is, after every fifteen minutes I have to send some data. So need Alarm Triggered after every 15 Min. I am using AlarmManager but not achieving. Calendar cal = Calendar.getInstance(); cal.set(Calendar.HOUR_OF_DAY,5); cal.set(Calendar.MINUTE,10);//...

Call Activity Method from BroadcastReciever

android,android-activity,broadcastreceiver,alarmmanager,android-pendingintent
I am trying to call from my BroadcastReceiver(ReceiverSchedule) to call a method (CancelSchedules) in my Activity(ViewScheduleActivity). The main problem I have is that it the Activity becomes null on the onReceive. I think I'm simply passing it into the intent wrong. I have tried the following link: Call an activity...

AlarmManager With BroadcastReceiver Not Firing

broadcastreceiver,android-service,alarmmanager
I have an AlarmManager that is set in a BroadcastReceiver subclass using a Service subclass as the context. The AlarmManager is not firing. I know that the AlarmManager is being set with the correct milliseconds. Any ideas for why the AlarmManager is not firing? public class Alarm extends BroadcastReceiver {...

Android registerReceiver Inside runing service that waiting for AlarmManager system msg

java,android,broadcastreceiver,alarmmanager
I have running service which includes broadcast receiver . I need the broadcast receiver to get the message from system timer clock interrupt that Alarm Manager made. The main idea behind this is that when user close the app the service will continue listening until time interrupt happens . I...

Relationship among Service, Alarm Manager and Broadcast Receiver

android,service,broadcastreceiver,alarmmanager
I am new to Android Development and would highly appreciate if someone could please explain me the relationship among the Service, Alarm Manager and Broadcast Receiver with some sample code. I am working on an Android App where I need to execute certain part of a code every 10 minute....

Android periodically get location and post to server using Service

android,android-service,alarmmanager,locationlistener
I use a service class that implements LocationListener, to get the location at periodic intervals, and post to server at only when there is considerable change in the latlon(min 100 meters). Because, continuously updating server drains battery quickly. I start this service from onCreate() of myActivity, and don't call stopService()...

AlarmManager - How to set a Notification to appear annually

android,notifications,alarmmanager,date-of-birth
I want an notification to appear each year depending on the date entered (Birthday). I have everything else working bar how to set a notification annually. As you can see below I have changed the code to say "HERE" where the intervals go. There are intervals for days and I...

AlarmManager cancel() not working

android,alarmmanager,android-pendingintent
This is my first post here. I have searched all around for this topic, but nothing seems to help. When the code below gets executed, the alarm still goes off, when it should not.. meaning that I cannot cancel the alarm, making my app useless for API's lower than 21....

Issues scheduling alarms when getting the time to set the AlarmManger for using a TimePicker because of AM/PM

java,android,android-intent,sms,alarmmanager
I'm programming an app that has a feature that the user can use to set an alarm for an SMS message to be send to someone. The problem I am having is say the user sets the Alarm-Manager to go off at 9:00 A.M. and it is currently 10:00 P.M....

Notification size when not showing first

android,user-interface,notifications,alarmmanager,remoteview
I'm using local notification like clock alarm with buttons to control it. My problem is that the Notification view isn't wrapping my content. So after searching around I found out that there is a workaround to achieve this by setting the view after build. Something like this: Notification notification =...

scheduling service using AlarmManager in android

android,service,alarmmanager,scheduling
I'm trying to schedule a service through AlarmManager with following code: The onCreate() of MainActivity is as follows: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* if(isMyServiceRunning(MyService.class)) { Toast.makeText(this, "Service already Running", Toast.LENGTH_LONG).show(); } else{ startService(new Intent(getBaseContext(), MyService.class)); } */ AlarmManager alarmManager; PendingIntent alarmIntent; Calendar calendar = Calendar.getInstance();...

AlarmManager not creating an alarm

android,alarmmanager
I'm attempting to add some "reminders" functionality to my app. I want to set up an AlarmManager and fire a Notification when the alarm happens. I've added a few methods to create an alarm, cancel an alarm, and see if an alarm is active. The following code is in Settings.class...

Update currently used app

android,user-interface,alarmmanager
I am currently experimenting with AlarmManger and I have manageed to make it run in the background and I am also able to make a toast, but what I have not figured out is how am I supposed to edit something in my UI? Example: I have my MainActivity, the...

Checking AlarmIntent from different Activity

android,android-intent,android-activity,alarmmanager
I create a repeating alarm Intent intent = new Intent(StartActivity.this, NotificationService.class); intent.setAction(NotificationService.ACTION_PULL_NOTIFICATION); PendingIntent pintent = PendingIntent.getService(getApplicationContext(), 0, intent, 0); AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE); alarm.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis(), updateFrequency * 1000, pintent); This works as intended so far. I check if my alarm is active with this Intent intent = new...

Not getting notification on future time

android,service,broadcastreceiver,alarmmanager
I want to show a notification to the user even after if user closes the application. But i am not getting the notification for the future time like i want to get notify user every day at specific time. **Here what i have tried** > Calendar c = Calendar.getInstance(); int...

AlarmManager Elapsed Real time Not Working?

android,service,alarmmanager,alarms
So I am new to the elapsed realtime alarm, and I tried to make my service run after the phone was turned on, but the service doesn't seem to get run. Setting Alarm. Intent sintent=new Intent(getApplicationContext(),alrmsetter.class); PendingIntent setter= PendingIntent.getService(getApplicationContext(),137,sintent,0); AlarmManager mmanager=(AlarmManager)getSystemService(ALARM_SERVICE); mmanager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,6*1000,setter); Service public class alrmsetter extends Service { public...

android alarm manager does not work after phone is restarted

android,notifications,alarmmanager
i am using following code to alert users using notifications at a specific time about new updates in the app every thing works fine and we receive alerts at the desired time here is the mainactivity.java public void setAlarm(){ alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmIntent = new Intent(MainActivity.this, AlarmReceiver.class); pendingIntent =...

Android check for system date to change then run code

android,alarmmanager
What is the best way to go about running code immediately on system date change? Currently I am trying to set the wallpaper on a device based on the date. If the date changes, I will set the wallpaper to a new image. My code for getting and setting the...

Android : AlarmManager is not wroking properly. It is not able to set the alarm

android,android-intent,alarmmanager,android-pendingintent
Here is my code Code to set Alarm. This is the code I tried, but unfortunately it won't set the Alarm at all. Please help me with this. The AlarmManager is the only way I know to set alarm. Could anyone tell me if ther is some other way. I...

Unable to check if alarm has been set by AlarmManager

android,android-intent,service,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), PendingIntent.FLAG_NO_CREATE) != null); if (alarmUp) { // alarm is set; do some stuff } Intent alarmIntent = new Intent(MainActivity.this, AlarmReceiver.class); final...

Activity shown immediatly instead of showing a notification

java,android,notifications,alarmmanager,android-pendingintent
I'm trying to use the AlarmManager to send a notification to the user later in the day, whether he is using the application or not. I basically pasted what I saw here : http://developer.android.com/guide/topics/ui/notifiers/notifications.html, but obviously something went wrong because instead of showing a notification, the AndroidLauncher Activity is shown....

AlarmManager - Am I doing it right?

android,broadcastreceiver,android-service,alarmmanager,android-broadcast
I had setup AlarmManager in my MainActivity class. A class called AlarmReceiver gets fired up for every set interval of time. I have to perform an operation when that class is fired up. That code is in in another class Parsing.java Now in AlarmReceiver.java, I'm doing this : public class...

How to Create a Distinct PendingIntents

android,alarmmanager,android-pendingintent
I have an app that allows a user to create a reminder to alert them in the future. The issue I am running into, is that as a user creates more than one reminder, the pending intent only triggers on the latest one created, with the earliest reminder content to...

Notification Message Instantly Fired - Android

android,time,notifications,broadcastreceiver,alarmmanager
I'm making an app that stores medicines data in an SQLite database in order to send to the user notifications when it's time to take them. I already created the BroadcastReceiver class and managed the notification Intent. The Calendar.set() function is called when I add the time (hh:mm:ss) in the...

Android: Reminder concept with Alarm Manager

android,sqlite,alarmmanager,android-broadcast
I tried to make reminder application for Android, followed tutorial from this website Set Notification for Specific Date. Basically it used Alarm Manager to create a reminder. This code used to call alarm manager and show notification on specific date. reminderClient.setAlarmForNotification(calendar, uniqueid, interval); I save all of the reminder in...

AlarmManager is discarded when application is cleared from background

android,broadcastreceiver,alarmmanager,android-pendingintent,android-broadcast
This is how I am creating an alarm. When the app is still running in background the alarm is fired. but when it is cleared from the recent apps, the alarm is getting discarded. I am registering a new receiver and providing a unique action for differentiation between two alarms....

Sending alarm broadcast to a dynamically registered receiver

android,broadcastreceiver,alarmmanager
I have an anonymous class broadcast receiver: private BroadcastReceiver mMyReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateStuff(); } }; I register it and create a pending intent: Creating pending intent and registering the receiver context.registerReceiver(mMyReceiver, new IntentFilter()); Intent intent = new Intent(context, mMyReceiver.getClass()); mMyIntent...

Alarm Manger doesn't work on time

android,alarmmanager
i have this method which should schedule alarms but when the time arrives it doesn't start the pendingintent ?? public void setAlarm(String name, long time) { AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent dialog = new Intent(this, SubActivity.class); dialog.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pi = PendingIntent.getActivity(this, 0, dialog, 0); if (Build.VERSION.SDK_INT >= 19) {...

How to create alarm with date, time and repetition for some days(suppose 10 days) which show alert even the phone is reset or lock?

android,broadcastreceiver,alarmmanager,android-alarms,repetition
I am creating a reminder application for that i want to create a alarm with date time and number of days repetation. As i am new in android development can any one please help me with this? I have check this link...

Scheduled Alarm Manager not working Android

android,broadcastreceiver,android-service,alarmmanager,repeatingalarm
I am trying to start an alarm service that repeats every day at a particular time. I have gone through a lot of threads on stack overflow regarding this but no luck. I followed a few tutorials: http://karanbalkar.com/2013/07/tutorial-41-using-alarmmanager-and-broadcastreceiver-in-android/ and http://javatechig.com/android/repeat-alarm-example-in-android My service is never started and I do not understand...

Multiple Alarms, Few Works and Few does not

android,alarmmanager,android-pendingintent
stuck around into a problem with AlarmManager I developed a method which adds two alarms into an AlarmManager Array. My method given below runs on a button click and adds as many as 10 alarms in the AlarmManager Array two per click. My method code is given below. public void...