Skip to content

Instantly share code, notes, and snippets.

@ubarua123
Created January 14, 2020 06:21
Show Gist options
  • Save ubarua123/6d349564d71fc611b3ca779a11f9b256 to your computer and use it in GitHub Desktop.
Save ubarua123/6d349564d71fc611b3ca779a11f9b256 to your computer and use it in GitHub Desktop.
public class SampleApplication extends DaggerApplication {
@Inject
WorkManagerWorkFactory customWorkerFactory; // Field injection of our custom worker factory class
@Override
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
AppComponent component = DaggerAppComponent.builder().application(this).build();
component.inject(this);
return component;
}
@Override
public void onCreate() {
super.onCreate();
// INit our worker manager
WorkManager.initialize(this, new Configuration.Builder().setWorkerFactory(customWorkerFactory).build());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment