Reputation: 61538
Is it possible to use dependency injection with the reference implementation of CDI (Weld) on Android?
If yes ( as Weld seems to need java 1.5, there should be no real obstacles) - are there any examples/resources?
Thank you
Upvotes: 2
Views: 2400
Reputation: 884
Since this was the first thing I was missing on Android, I created it as the core feature of the BARACUS Application framework for Android 4+ Applications.
In order not to have an Annotation-based or code generation based overloaded system, it leverages dependency injection by type, therefore you simply can register an interface plus implementation (useful when you want to write android-aware testable components) or plain java class in the context bootstrap phase.
Also, it allows to have a Java EE styled bean and a spring styled context lifecycle.
The stuff is Apache 2 licensed and hosted on github. Feel free to reuse any code for your purpose.
Upvotes: 2
Reputation: 52936
Not really. Weld is quite resource consuming, so you certainly don't want to put it on a device with limited memory. You might wan to try roboguice if you need a DI framework for Android.
Upvotes: 3