Open GoogleCodeExporter opened 9 years ago
This would help Android developers using guice.
RoboGuice allows developers to inject views and resources into their Android
applications. Because some of these objects cannot be determined at injection
time (such as views, which only exist after setContentView() is called from
onCreate()), we use a type listener to process a custom injection annotation
(@InjectView(id) and @InjectResource(id)).
This works great. However, users expect to be able to access their resources
statically. If they try to "@InjectResource(R.string.foo) static String foo",
they get null because the TypeListener was never called.
I've tried overloading requestStaticInjection in my module to manually invoke
hear on my type listeners. This works fine for any bindings that ship with
RoboGuice, but it doesn't work for bindings that are provided by users in their
own modules.
There seems to be no technical limitation in the TypeListener interface that
prevents them from working on static fields. I've verified that my
TypeListener injects the static fields properly if I invoke it manually by
calling injectMembers. Looking through the Guice code it seems like one would
just need to loop over the type listeners in InjectionRequestProcessor.
Original comment by mbur...@gmail.com
on 27 Jan 2011 at 1:33
Original issue reported on code.google.com by
mbur...@gmail.com
on 9 Dec 2009 at 5:01