-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@ApplicationContext doesn't work with fragments. #2
Comments
As a workaround, have you tried using |
Thanks, it works. But this way of initialization wasn't clear for me when I ran into this issue. Maybe it would be better to make some initialization method which will take Context or (maybe even better) Application? |
Yep, exactly. I thought on the moment that it would work for most cases and then I forgot about it. |
Thank you for this lib, it's great! |
Can you please give an example for that workaround? |
public class YourApplication extends Application {
@Override
public void onCreate() {
AsyncService.inject(this);
}
} Don't forget to declare this application class in your |
Thanks a lot! Your work is appreciated :) |
Service field annotated with @ApplicationContext is null when injecting service into fragment.
Here's code from fragment:
PdfGeneratorService:
Further investigation lead me to AsyncService.java, and here's the code that supposed to get Application context from object.
But fragments doesn't have context, so I need to have a way to pass some context while injecting into fragment. Maybe some kind of builder approach for this would be better for this?
The text was updated successfully, but these errors were encountered: