0

In the last year I have bought 4 different Android phones and all of them had got failures with the calendar notifications. Sometimes the notification for an event was shown and sometimes wasn't shown at all. I investigated a lot and found a problem in the "Calendar Storage" app, a Content Provider that is in the application framework layer. Notifications stop to be always shown as of the version 6.0.1. That's the reason why I want to develop my own calendar app that is not based on the Calendar Provider so that I can have reliable notifications again.

In the past, when we developed a reminder based app we used AlarmManager class and the method setExact() for make the application able to show a notification or anything else at a given date and time in the future. But in Marshmallow and upper it mustn't work because of the annoying doze mode.

They invented the method setExactAndAllowWhileIdle() in Marshmallow supposedly for setting alarms that can bypass the doze mode. But it says that it doesn't let you to put more than one alarm within 15 minutes. In a reminder based app that is a foolishness as the user MUST be able to put as many reminders as he wants and as close in the time line as he wants.

So my question is, how can I make my app to show reminder notifications at a given time in a way that always works regardless of the doze mode and so that I can have as many notifications as I want and as close in time as I want?

Thank you.

user3289695
  • 740
  • 1
  • 9
  • 20

1 Answers1

0

There's always the option of white listing your app so doze will still let it run the old way.

Another official way of making it work is sending an fcm notification, but you'd need a server to do the job.

Short from that I'm afraid the next official answer involves exact alarms.

If it's an option for you there is a chance you can start a service with STICKY. I'd expect the phone to never go into doze properly even if the service thread is blocked forever (it may help to assign it to a different process in the manifest so your ui never freezes). Putting a periodic old style Java timer to fire a callback at the right time may accomplish what you need.

Fabio
  • 2,654
  • 16
  • 31
  • I have investigated and found that although an app is white listed it still is messed around by doze sometimes, so that option shouldn't be valid. Also, the GCM isn't suitable, it is an invention by Google by the only purpose of taking us our money away. Really, a reminder application should never ever use a remote server unless it had any synchronization functionality. Mine doesn't. Is there any other way? What are exact alarms? – user3289695 Aug 08 '17 at 13:57
  • It's what you were already doing. There's some interesting twists to it though : https://stackoverflow.com/q/38094420/2754856 – Fabio Aug 08 '17 at 14:06