0

In my project I need to make a network call after every 30 minutes I start my app. For network call, I am using Retrofit. After searching a while I came to know about FirebaseJobDispatcher. Is it the most convenient way to schedule using FirebaseJobDispatcher for this type of call? Please help me.

mark922
  • 1,136
  • 2
  • 11
  • 20

1 Answers1

0

What you are trying to do can be done in multiple ways.

1. You can use JobScheduler & JobIntentService / JobService

  • If you use JobScheduler then your job will not run when the device is in doze mode.

2. You can use the AlarmManager & Broadcast receiver that will run every 30 minutes

3. You can use as you mentioned; Firebasae Job dispatcher: actually uses JobService and backward compatible to Api level 9

-- All these are for scheduling your background service as per your need and you can make the network call using retrofit. With JobService or JobIntentService you can specify the type of network you require to make the api call, for example if you want your network request to be made only when wifi is enabled. For AlarmManager you have to get the type of network yourself if you want similar functionalities.

MRah
  • 940
  • 6
  • 15
  • I have tried Firebase Job dispatcher with the following options : setRecurring(true), setTrigger(Trigger.executionWindow(0, 20 )) . But now the problem is not in every 20 sec the service is being triggered. What is the solution for this? – user2396066 Aug 07 '18 at 08:03
  • Minimum trigger execution time for JobDispatcher is 30 seconds, you can follow the issue here, https://github.com/firebase/firebase-jobdispatcher-android/issues/124 – MRah Aug 07 '18 at 14:54