Android Alarm Reminder - android

I have an app which is loading upcoming dates (like Birthdays) from an SQLite database
and showing it on a ListView. That works fine.
What I now want is to inform the user regular by an Alarm or Toast or something without
starting the application. The user has the only option when to inform: on the same day or 1 day before and the time!
Has someone an idea how to realize this? Maybe a Service or a Timer, or both?
I would be very pleased about some tips.

Take a look onto AlarmManager. Also note that the service doesn't persist alarms between sessions so you'll need to re-setup them after device boot. Another option may be using Google calendar API to create birthday events, notification will be handled by Google calendar app then.

Related

Android studio, unlocks the activity everyday after a given time

I have this quiz, when user take the quiz I get the created_at time and I want it to be available after the same time tomorrow until then it should be locked. How do I schedule the task? Can anyone give me a hand?
You can manage it using server time. So you use a scheduler and check the server time and set your logic.

How to make your app do something even when you're not doing anything or even using it

This question is vague but I am not sure what to Google for exactly.
But in my app I have a section where you create a list of tasks with various attributes, and a lot of these numbers are summed up and displayed in daily totals visually. But these daily totals should reset every 24 hours (based on the hour of the day the user chooses for the cutoff, e.g. 3 am if someone works late).
Right now: my database can hold all the data by day. Then my daily counters will visually display the numbers by pulling the corresponding data from the database looking for the current day. That's the easy part.
The hard part: I can refresh the counter after the time cutoff if the user rotates the screen or restarts the app because then it'll be looking for items in the database with a new day that won't be found, so everything will be 0 as intended. But what if the user is just staring at the screen as the time cutoff rolls by? How do I make the app refresh the counters once the time hits? What if they're not even using the app at all (either it's minimized in the background or not even active).
Do I need to have some kind of always-running loop in the background that checks the current time against the values in the database? If so, isn't this inefficient if it's always needing to pull values from a database based on time? What's the correct practice for something like this?
You can setup a service and schedule that service to run periodically so that it does whatever job you want it to do
maybe this article can help you.
Alarm manager and services will be ideal for you to implement to do something for your requirement.
Services : It will be running all the time irrespective of your life-cycle of activity.
Alarm manager: Inside services use alarm manager to trigger event to update UI at regular interval.
Finally you can use Local braodcast reciever to update your Activity from services.
You can check implemetation in details below :
Android update activity UI from service

Do something at a certain time of day in an android app

I'm writing a reminder app for Android where users can create custom notifications that will appear at a time of the day that they specify. I realize that there is another similar question, but the only answer was to use the AlarmManager, which, according to the documentation, resets when the device is rebooted. I want the user to be able to set a notification to appear at a certain time on a certain date, meaning that it should retain the information through a reboot.
Ultimately though, the app needs to be notified that it needs to do something.
Eventually, I would also like to have the same behavior when the device reaches a certain location, if you have any thoughts on that. :)
Bear with me, I'm a bit of a novice programmer (I'm 17).
Thanks in advance.
The commentors are correct: you will need to use an AlarmManager to create your alarm and you will need a boot receiver to handle resetting your alarm after a reboot.
GeoLocation and GeoFences are pretty easy. I have an example app here: https://github.com/androidfu/GeofenceExample
You're not going to care about the mock location bits in that example unless you wish to test entering and exiting your target location, but the rest of the code should work for what you need.
Also, GeoFences do not persist a reboot either so it'll be good for you to get familiar with your on-boot receiver ;) You'll want to re-add your GeoFence after a reboot too.

In-app notification triggered from a background service android

Lately I am developing some new features of the app. My app is about displaying different events that are happening in a specific time and in a specific place.
Now I want for the user to be able to save a event like his favorite, which means that he potentially wants to attend that particular event. When a user mark an event as a favorite one, the time of the event and other details like place, name, description will be store on the device. Now the part that I am having some difficulties is the notification part.
What I want to do is that when the time is 1 hour before the beginning of the event a notification must be triggered in order to tell the user that the event will start in an hour. If I will say its an analogy with the agenda notifications.
Now the problem is to the right way of implementing it. I know how to use Notification in Android and also I know how to use background services . I have followed a lot of tutorials like : http://www.tutorialspoint.com/android/android_services.html, but I don't know which is the right way of implementing it.
One way is to store the data in a database, and run a background service to check periodically if the time of the phone is the right to trigger a notification for an event.But this would say that the service would run indefinitely in the background.
I also thought about using some store procedures in the database that check the values that are store over there and when the time comes, it triggers the service that triggers the notification.
I don't know if I am following the right way and I need to clarify these before I proceed.
Is there any tutorial to help me or any other idea that helps me achieve the same thing.
One way is to store the data in a database, and run a background service to check periodically if the time of the phone is the right to trigger a notification for an event.But this would say that the service would run indefinitely in the background.
This is rather wasteful. Is is the programming equivalent of the children in the back seat of the car chanting "are we there yet? are we there yet?".
I also thought about using some store procedures in the database that check the values that are store over there and when the time comes, it triggers the service that triggers the notification.
This is not supported in Android.
or any other idea that helps me achieve the same thing
Use AlarmManager to tell Android to give you control one hour before your event. The PendingIntent that you use with AlarmManager can trigger a BroadcastReceiver in your app that can raise the Notification.

Register action at future intervals

I'm experimenting with Android and would like to make an app that sends predefined texts to certain people at future intervals. Basically, initiating conversations with relatives every month or so, so they think I like them.
How do you register an activity or app to fire in the future? I'd like to be able to change up the greeting, so that the relatives don't catch on.
Thanks for your help!
You can use AlarmManager to trigger your app in the future. Here's a tutorial on how to use it: Scheduling Repeating Alarms

Categories

Resources