3

I need to implement calendar notifications similar to Google Calendar notifications. Notifications should work offline, so FCM is not an option.

I tried to use Firebase Job Scheduler, my schedule is created like this:

FirebaseJobDispatcher dispatcher = new FirebaseJobDispatcher(new GooglePlayDriver(context));

Then schedule job:

Job myJob = dispatcher.newJobBuilder()
    .setService(MyJobService.class)
    .setTag("my-unique-tag")        
    .build();

dispatcher.mustSchedule(myJob);

My problem is that above code only schedules single job (it probably also could be sheduled as periodic job). I need to schedule notifications for all events from my internal app calendar, for each date.

I think creating multiple jobs is not a good idea (since, afaik there is some limit for jobs count per app). Can you show me the best solution to do what I want?

user1209216
  • 7,404
  • 12
  • 60
  • 123
  • you can also do like this: start first service and when it is finished start another within that process. – Umair Apr 04 '18 at 06:20
  • one more thing are you using async task for services and what about calender, is it your's or using google's ? – Umair Apr 04 '18 at 06:30
  • Why don't go for [AlarmManager](https://developer.android.com/reference/android/app/AlarmManager.html) ? – Paresh P. Apr 04 '18 at 06:34
  • There are some limitations for AlarmManager on Oreo. I think AlarmManager is deprecated now – user1209216 Apr 04 '18 at 06:43
  • @Umair my own calendar. I don't want application to hold wakelock and battery drain. But job should be triggered even when app is not running – user1209216 Apr 04 '18 at 06:45
  • Deprecated? Who said that? Kindly go through this [documentation](https://developer.android.com/topic/performance/scheduling.html) – Paresh P. Apr 04 '18 at 06:46
  • @user1209216 what I did was I called multiple services like i told you even when my mobile screen was off it ran and all worked fine. (But I am using firebase so not sure how it will work on locally). – Umair Apr 04 '18 at 06:51
  • As far as I understand, your solution won't work offline on Oreo. You will get exception if you try to start another backround service in background, it's not allowed – user1209216 Apr 04 '18 at 06:54

0 Answers0