yigit / android-priority-jobqueue

A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
3.4k stars 395 forks source link

persisted jobs and dagger injection #91

Closed mariuspena closed 8 years ago

mariuspena commented 8 years ago

Hi

Built a job, that uses an injected service (Dagger). Scenario:

What should I do ?

PS: how do I inject the service? something like this: http://stackoverflow.com/questions/35022074/how-do-i-inject-an-object-into-android-priority-job-queue-with-dagger-2

yigit commented 8 years ago

see the example in the dev summit demo: https://github.com/yigit/dev-summit-architecture-demo/blob/master/client/app/src/main/java/com/android/example/devsummit/archdemo/di/module/ApplicationModule.java#L103

You can assign a dependency injector when you configure the job manager. Unfortunately, Dagger2 does not support base class injection so you'll have to have a custom BaseJob class where there is an onInject method. Then the jobs should call the injector to inject their dependencies when onInject is called.

mariuspena commented 8 years ago

thank you very much. my main problem was that I was using inject with a BaseJob and Dagger 2. that was a no no.