I have to develop android app which must schedule different notifications in a distinct date that is in the future. I have the idea to not schedule using AlarmManager in an Activity class for all notifications in the same time in my app but instead using a service in the app that can each 24h(= per day) verify if there is one or more than one notification to show today for the user of my app. My datas are many dates in the future that specify the time when the user must be notified. What is the best practice ? And you 're welcome if you have another kind of solution.
I don't think it's a good idea to implement a service for alarms like you describe. AlarmManager was made for this purpose. If you were to implement a service, first you would be taking resources 24/7, and the user isn't going to like that. Second, how are you going to notify the user if the device is asleep? It seems overly complicated. Is there a reason you don't want to use AlarmManager?
Related
Can anyone tell me how to do a service that will generate a notification every day at a certain time (for example at noon)?
Or rather, do I need a service to do this?
Naturally I am talking about Android programming
In Android, You can implement with options:
AlarmManager
Schedule job
Server schedule job
Or something other options,...
I want my app to do is: Once a day check if the user have written a note, If not, add a notification to the statusbar, reminding the user to start the app, and write a note.
Can I use the alarm-manager or do I have to use a Service for this? Do anyone know where to find a good tutorial on this, or have some example code ?
Use AlarmManager. Permanently running a Service just for scheduling a regular task would be an overkill.
Have a look at this question, for example: AlarmManager Android Every Day
Situation: We have more than 5 android applications which are modular (and really limited in terms of functionality) and each has it's own IntentService in which it gets data from internet and stores it locally.
Also one app is core/main app. Now I want, that each app updates its data during the night. I don't want to put code for alarm, receiver and other stuff into every app. I want that core app sets Alarm, and when alarm goes off, then core app calls all IntentServices of every app.
Question: How can I prevent that system goes to sleep during the execution of services?
One solution is that I use #CommonsWare implementation of WakefulServices in every every app instead of IntentService, but I don't really want to change code in all the apps. Is there any elegant way to solve this?
Thanks #CommonsWare your thoughts were really helpful.
So to conclude, solution is that every app implements WakefulIntentServices and then core app starts WakefulIntentServices of all the apps.
I am developing a birthday reminder app which will notify user on specified date the birthday event. I have googled web and found alarm manager in android to carry out my task.
But i just want to make sure is this the only way followed in making apps like reminder or we have some methods also
I checked this tutorial
Yes, Alarm Manager is what you want. Don't forget to register a boot receiver to set your alarms back up after a reboot.
Also no this is not the only way. but other ways are more complicated still, and potential less reliable. For example you could save the date/time to a server, and have it send a push notification to set off the alarm at the appropriate time.
However Alarm Manger was intended for things like this, so best use it. There is always more than one way to do things, and any clever person can come up with a hackish way to do something. But Alarm Manager is easy, and standardized.
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.