I have to display some notifications from my app on fixed date and time which is selected by the user which are sort of reminder.
It can be done using the ALARMMANAGER by android. I am not able to find any example or code to set the alarm on the desired date.
Or if I can add and remove an event to the calendar.
Any help please.
You need to implement service that will be responsible for the scheduling
Schedule Notification after some time
the link above shows you how to do that along with that you can use Timer Class of Android.description of which is here Timer Android
Related
I'm trying to add alarm feature to my app or reminder with notification and I found a tutorial uses Alarmmanger for that but I wonder if is a new way is better for that, is workmanger good over alarmmanger?
the function of the app gonna be like that:
user add a note with time and date and choose which he prefers to remember the note as alarm or reminder
if it is alarm, the phone gets and alarm notification with ring sound and dismiss button on notification and if he clicks on the notification he get back to the app with alarm screen and he able to dismiss it or postpone
if it is a reminder, the phone gets a simple notification with sound with dismiss button in the notification.
so what is the best practice to do that, and it would be favor if you provide with me with tutorials about how to implement that
https://developer.android.com/guide/background#recommended-solutions
Per your description, it seems you fall under:
Exact tasks
A task that needs to be executed at an exact point in time can use AlarmManager.
To learn more about AlarmManager, see Schedule repeating alarms.
Actually I need to trigger an action(Intent) for the calendar events start time.
I had used the Calendar database to read the events title,start time and end time.
By passing the first start time to the alarm manager, I was able to trigger my action only once. My main problem is how to continue this process by passing different time intervals to the Alarm Manager.
Or is there any better solution to notify the action(Intent) ??
Thanks in Advance
It appears there is no intent to act on using a broadcast receiver.
You can however, read the event instances manually and schedule background tasks using the AlarmManager.
Credits to this answer on a similar question
I am a newbie to android , and I am designing an app that reminds event , I am not aware of how to get started to achieve this .
I stored the Date Month Year of the event in the database , the thing I need is
Run a background service that looks for the event to occur
push notification based on time set by the user , also days set that is 1 days before , 15 days before
Please help me how to achieve this
Use the AlarmManager.
You can register a pending intent to be triggered at any time, or periodically. You can then make the pending intent trigger a broadcast or a service or just a notification, if I remember correctly. Just check this or google for Notification / AlarmManager.
This way is more power efficient than just run a background service that checks periodically if it needs to notify the user.
I want my app to start automatically every month on a particular day(Specified by user).
I searched a lot on Google, but I din get any solution. I got alarm for seconds like the app starts after a particular seconds. I am new to android. So an example will be highly appreciated
You are looking for the AlarmManager class.
Quoting from the documentation,
This class provides access to the system alarm services. These allow
you to schedule your application to be run at some point in the
future.
create a service with alarm manager ...........
and start the app when particular date comes
Is there a way to send a notification to the user that app has been downloaded but a certain task from the app is not yet complete even after certain period - say a month. One way is a background service which should come alive every month in this case, check the app state (in sharedprefs) and then send a notification. Is there some other easier way in Android without writing custom service.
Here's how I would do it. Schedule an alarm using the AlarmManager to go off a month from today. That alarm can trigger some code inside of a Receiver or otherwise to check whether the said event has occured. If it hasn't, you can then show a Dialog or whatever.
In order to wake up your app after some amount of time (in your example a month) you're going to have to set an alarm. You can use AlarmManager for that. If all you're going to do is check SharedPreferences, you can do that in a broadcast receiver. You can send your notification there.