quarck / CalendarNotification

Android app extending calendar notifications with snooze button and notifications persistence
GNU General Public License v3.0
104 stars 39 forks source link

Not detecting calendar notifications automatically after upgrade to Android Oreo #271

Open asfernandes opened 6 years ago

asfernandes commented 6 years ago

I was using this app for a long time with Zenfone 3 with Android 7 and it was great.

I then update my (same) device to Android 8. Now the Google Calendar is showing the notifications and this app replaces Google's notifications only when I open it.

mmcev106 commented 6 years ago

When I swapped phones I was having a problem with notifications not appearing until I opened the app. The problem went away when I checked "Use setAlarmClock for events" under Settings -> Misc. Settings. Does that work for you?

asfernandes commented 6 years ago

It appears it does. Also, I removed the app from the zen fone application that controls battery usage.

mmcev106 commented 6 years ago

I'd have to do a little research figure out why that setting it required (on newer Android versions?). I wonder if it should be the default...

smichel17 commented 6 years ago

It shouldn't be required, per se. It's about battery management, and how precisely you want the event to fire.

It used to be thatAlarmManager.set() did the same thing that setAlarmClock currently does -- set an alarm at that specific time. But constantly waking up the phone to fire a bunch of alarms isn't good for battery life. It's better if you can delay some of the alarms and then fire them all at once. So Google changed the API so AlarmManager.set() will go off some time near when it's set for, and AlarmMamager.setExact() must go off exactly when it's set.

Next up: it's basically the same situation for when the phone is asleep. Waking it up all the time is bad, so Google added another callback, ...setAndAllowWhileIdle(), and made it so the default one just won't fire if the phone is in doze mode (basically, if the screen has been off for a while).

setAlarmClock is basically the ultimate override. It's telling the Alarm Manager, "Whatever alarm I'm setting, the user is absolutely counting on it going off exactly when I set it, whether the phone is asleep or not." That's the easiest for developers to work with because we know it won't break, but it's also the most battery intensive. If you can get away with not using it, you generally should (sometimes you can't, though. Certain parts of the AlarmManager interface are poorly documented and annoying as all heck to figure out how to make them do what you want. Plus Google is encouraging people to use JobScheduler now instead of AlarmManager, which has a supposedly saner api).

Anyway, that's a really roundabout way of saying, it should be possible to gracefully chose the right callback for the version of Android you're running and not have the setting, but it was probably done when @quarck was low on time, and this was the quickest way to get a fix out to people who needed it without impacting the battery life of those who don't. Or maybe there's other reasons I'm not thinking of.