I am developing a school application, some functions require creating notifications and alarm clocks for the following cases:
Option to add notifications or alarms to remember some school assignment, taking into account that the user can have multiple school assignments and create multiple alarms or notifications for each one
Activation of an alarm clock for each day of the week
Option to receive a notification a few minutes before starting each class
Currently I am storing the information of notifications and alarms in a database, I am using AlarmManager to schedule them and BroadcastReceiver to show them or reschedule them when restarting the device.
So far everything has worked fine but I don't want to start the production release because there is a high probability that users schedule a lot of notifications and alarms, I don't know if this could lead to problems such as not activated alarms or slowing down of the application, I don't want the user to have a bad experience with this feature
So my main questions are: Is there any limit or recommendation for the number of Alarms programmed by AlarmManager?, Is my approach correct?
Currently when adding the notification it is scheduled immediately with AlarmManager regardless of the date, but I have this other idea: Just store the notification information without scheduling it with AlarmManager until the day it should be triggered ... Would it be more convenient to create a only service with AlarmManager that runs, for example, every day at 03:00 am and to schedule notifications and alarms for the day?
I hope someone can help me, thank you very much
Related
Im trying to run a notification if a user has not opened an app in say 24 hours to encourage them to open it (Similar to duolingo style). Im using Java and I can set a periodic notification using workmanager but it runs while the app is open which is not what I want. I want the notification to run every 24 hours however if the user has opened the app this timer should reset, I've searched for this but can't find what I require exactly
I would recommend to use AlarmManager for your case. You can, for example, reschedule it in Application.onCreate() method to fire in 24 hours after user last launched an app. First you need to cancel previously scheduled alarm using cancel method, and then set a new alarm to fire in 24 hours using one of the set...() methods available in AlarmManager class.
My problem is: I need to start countdown timer in my app which will work independently my app is opened or closed ...or even if my smartphone is off.
I really wonder how does android standard clock app works. I mean how it counts time even when my phone is off? Could anybody help me with this? I will appreciate any answer!
Internal to an android device will be a clock which runs from the battery and potentially syncs with network time when it has signal.
You can use AlarmManager and PowerManager to get your code to run at specific times, even if the phone is turned off:
Sometimes, it may be necessary for your android app to complete a task
sometime in the future. In order to do this, you must schedule an
activity (can also be a service) to be run using Android’s
AlarmManager. This post will show: How to set up a receiver for the
scheduled event How to create an activity from this receiver Using the
AlarmManager and the created classes to successfully receive and
process a scheduled event
http://justcallmebrian.com/2010/04/27/using-alarmmanager-to-schedule-activities-on-android/
http://www.techrepublic.com/blog/software-engineer/use-androids-alarmmanager-to-schedule-an-event/
I develop an application which must manage the Alarm Clock in Android. I specifically need to do the following:
execute some code in my application when the user sets an alarm (also find out the time of the alarm at the moment of execution);
cancel an alarm when the user pushes a specific button in my application;
execute some code in my application when an alarm goes off.
I must mention that I am not interested in the CPU alarms, but the Alarm Clock application, which people use to wake up.
You can set an alarm using the intent described here.
However, you can not intercept the AlarmClock UI or ringing alarms as you seek to.
You might want to look into scheduling your own reminders, probably using AlarmManager with RTC_WAKEUP.
I'm working on an application where I need to show notifications 5 times a day ...from a foreground service..the purpose of using the foreground services is to be able to display notification even if the
application is closed . so I want to start the service as applications starts and schedule its notification timing accordingly I have tried using the snippet provided on android developers forum but its not working for me ... any help and sample code is highly appreciated Thanks
If the notifications are to be fired at a fixed time, you may not need a foreground service. It is a bad idea to keep a service running just to show notifications. Schedule those five times using an AlarmManager. You can find tutorial for it in google.
You would need to schedule alarms one by one. Foe ex..when alarm manager wakes your app the first time , then schedule a second alarm and son on.. You may not be able to set 5 concurrent alarm schedules. Do it one by one..
I want to write application which displays all the Alarms and Timers set in my device.
Lets take this scenario,
Assumption: In my device there is one system Clock application and I downloaded 2 third party clock applications.
Now lets say, I set 3 Alarms in system clock application and 2 Alarms for each other third party application.
So Now I have total 7 (3+2+2) Alarms set.
I want list of all those alarms in my single application. How do I get that list? I searched in Alarm Manager but not helpful.
Please Help. Thank you in advance.
the AlarmManager doesn't help you for this task - it just enables developers to schedule different tasks at a given interval (and repeating, too).
You would need to check if the single applications do actually share their information by utilizing a ContentProvider. If that's the case you would be able to get their data.
So sadly there is no unified way for this.