Can you please point me in the right direction how I would accomplish this? I want a user to select a time of day and then I want a notification to pop-up on their screen each day at that time. Thanks!
With KitKat, Google changed AlarmManager such that if you wanted the Service to start at exactly set time you had to use AlarmManager new method setExact (int type, long triggerAtMillis, PendingIntent operation). Erel implemented this in B4A as StartServiceAtExact. Now I have upgraded to...
Name: Find the next scheduled time. Description by example: You need to start a service each day at 5 am, 6:30 am and 8 pm. You need to find the ticks values of the next scheduled time, either today or tomorrow if it is after 8pm. Dim t As Long = FindNextTime(Array As Double(5, 6.5, 20))...
Thanks asales. I believe that will help me get the ticks for the user-specified time.
I'm still lost on how to pop-up a reminder at that time each day. Would some be willing to provide some code examples to get me pointed in the right direction? I just don't know how to have something running in the background and pop-up a notification at that time. Some basic code would be helpful to get me in the right direction.
You should make a service class to handle it. The service sets a "run again at this time" message that the OS uses to track it. When that time comes around it wakes the service up and let's it do its thing.
SOLVED. See next post for code. I have succesfully added a "quick event", but I am having difficulties when I try to add an "event" to Google Calendar, as I am getting the 400 error message: "Missing end time." I suspect that maybe the nested objects "start" and "end" are not correctly sent...
www.b4x.com
...May be it is safer... due permissions and unexpected STOP-broke services.. never tried but you can check it...
Thanks for all your help everyone! I got it figured out!
One thing I had to do to get the service to start when the app wasn't running was I had to change a setting for my app on my device. It was set to Restricted (restrict battery usage while this app is running in the background). I had to change it to Unrestricted (allow this app to use battery in the background without restrictions) so that the service would start at the specified time.
Any ideas how to make this change programmatically in B4A so that my app will run in the background and the service won't be stopped?