googlearchive / firebase-jobdispatcher-android

DEPRECATED please see the README.md below for details.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Service not registering from application onCreate()

chaddhaGaurav opened this issue · comments

Scenario:
I tried to schedule a periodic service from application onCreate() with following code:

val dispatcher = FirebaseJobDispatcher(GooglePlayDriver(context))
val job = dispatcher.newJobBuilder()
    .setService(MyService::class.java)
    .setTag(MyService.TAG)
    .setRecurring(true)
    .setLifetime(Lifetime.FOREVER)
    .setTrigger(Trigger.executionWindow(timeInterval, timeInterval.times(2)))
    .setReplaceCurrent(true)
    .setRetryStrategy(RetryStrategy.DEFAULT_EXPONENTIAL)
    .setConstraints(Constraint.ON_ANY_NETWORK)
    .build()
val result = dispatcher.schedule(job)

Problem:
Although the result is SCHEDULE_RESULT_SUCCESS, the service is never scheduled.
I confirm this by the output of this adb command :

adb shell dumsys activity service GcmService | grep myPackageName

In it's output, I don't see my service scheduled to run. But if I use the same code to schedule it someplace other (Like activity onStart() ) than the application onCreate(), the service gets scheduled and runs.

Is this a bug in the library?

In April 2019 we announced that Firebase Job Dispatcher would be deprecated today, April 7th 2020. For this reason we are going to close all open issues and archive the repository. We will also stop supporting FJD for new app installations (such as those targeting sdk versions greater than Android Q). Existing apps that rely on FJD should continue to function as usual.

While we will no longer work on FJD, we encourage you to migrate to Work Manager which is a superior tool and fully supported by the Android team.

Thank you for taking the time to try the library and provide this feedback. We sincerely appreciate your effort and we apologize for not addressing it in time.