How to inject final member in Activity without getting the blank final field error?

100 views
Skip to first unread message

brya...@hotmail.com

unread,
Feb 28, 2012, 5:01:59 AM2/28/12
to roboguice
How to inject final member in Activity without getting the blank final
field error?

Can it be done by the activity contractor? Is this the best way to do
what I want? If it can, please kindly provide an example. Thanks in
advance.

Michael Burton

unread,
Feb 28, 2012, 2:06:28 PM2/28/12
to robo...@googlegroups.com
final fields can only ever be assigned via constructor in java, so yes, you'll have to use constructor injection.

Mike





--
You received this message because you are subscribed to the Google Groups "roboguice" group.
To post to this group, send email to robo...@googlegroups.com.
To unsubscribe from this group, send email to roboguice+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/roboguice?hl=en.


brya...@hotmail.com

unread,
Feb 28, 2012, 8:38:07 PM2/28/12
to roboguice
Hi Mike

However Activity class require at less one empty constructor. If what
you said is true, and the this statement also true. We could not use
Roboguice to inject final member in Activity class, am I right?

Bryan



On Feb 29, 3:06 am, Michael Burton <m...@niskala.org> wrote:
> final fields can only ever be assigned via constructor in java, so yes, you'll have to use constructor injection.
>
> Mike
>

Cherry Development

unread,
Feb 28, 2012, 8:47:10 PM2/28/12
to roboguice
Yes. You effectively can't inject into a final field on any object
not instantiated by RoboGuice.

brya...@hotmail.com

unread,
Feb 28, 2012, 8:49:40 PM2/28/12
to roboguice
Hi Cherry

Thanks for your clarify.

Bryan
Reply all
Reply to author
Forward
0 new messages