Dagger: AndroidInjection is missing Service injection

Created on 23 Feb 2017  路  7Comments  路  Source: google/dagger

Add support for injecting android.app.Service classes. AndroidInjection supports injection into Activity and Fragment classes, but not Service classes. Just like Activity and Fragment, Service classes are components created by the Android framework, as opposed to classes created by application code.

Most helpful comment

Yup :) we were starting off with just Activities and Fragments as those have the highest value and we wanted to make sure we didn't miss anything with the API. Services (and BroadcastReceivers) will come shortly!

All 7 comments

Thanks for the feedback. This is on our roadmap and we hope to have it soon.

Just to be clear - Service injection is as straightforward as Activity injection, identical approach.

Yup :) we were starting off with just Activities and Fragments as those have the highest value and we wanted to make sure we didn't miss anything with the API. Services (and BroadcastReceivers) will come shortly!

Perhaps you can convince the Android framework team to add BroadcastReceiver.getApplication() to make it less hacky for O? :)

The BroadcastReceiver.onReceive() method has a Context, I think that's totally fine to use and better than waiting for a feature in O.

The BroadcastReceiver.onReceive() method has a Context, I think that's totally fine to use and better than waiting for a feature in O.

I just think it's a good opportunity - I'd say Dagger is a strong argument to try and get the method added to BroadcastReceiver; from an API design perspective I feel it should've been there from the start for all Android component types (except maybe ContentProvider).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pedrovarela86 picture pedrovarela86  路  3Comments

matpag picture matpag  路  3Comments

feinstein picture feinstein  路  3Comments

SAGARSURI picture SAGARSURI  路  3Comments

peter-tackage picture peter-tackage  路  3Comments