Dagger and AndroidAnnotations - how to inject @Pref, @Bean, etc?

Eugene

I'm using AndroidAnnotations in my project and just hooked Dagger + Robolectric + Espresso in.

Currently I have an Activity with SharedPrefences and a class 'injected' by AndroidAnnotations.

public class SomeActivity extends Activity {
  @Pref Prefs_ prefs;
  @Bean SomeManager mManager;
}

Now if I want to use a Dagger to inject these two, what my @Provide methods should look like?

Thank you very much.

WonderCsabo

Your @Provide methods should call the getInstance_ method of generated bean classes. This methods creates a new instance and injects the necessary objects. For the generated preference, you should call the constructor new Prefs_(context). However, this is not a too clean way since these generated methods are supposed to called by AA. Also Dagger integration is only working in the snapshot release, check out this thread. But as you can see, you can use Dagger now, but it is not convenient, and it seems to be better to just use AA injection for the AA generated classes for now.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Inject view in fragment with AndroidAnnotations

From Dev

How to tell Junit/Mockito to wait for AndroidAnnotations to inject the dependenices

From Dev

How to inject one bean to a set of bean in spring?

From Dev

How to inject ApplicationScoped bean in Stateless bean?

From Dev

How to inject raw Class to bean

From Dev

How to inject bean in a Tapestry service

From Dev

How to inject raw Class to bean

From Dev

How to inject bean in a Tapestry service

From Dev

How do I inject into a Servlet with Dagger 2?

From Dev

How to inject an anonymous inner class with dagger?

From Dev

How to inject pojo dependencies using dagger 2?

From Dev

How to inject a prototype bean in a Spring singleton Controller

From Dev

How to inject a bean in this MongoDB connection case?

From Dev

How to correct inject map of bean in spring context

From Dev

How to inject a @Named bean into a Junit test

From Dev

Spring: How to inject a String bean to the constructor?

From Dev

How to inject fields in bean-methods?

From Dev

How to inject bean validator automatically enabled by JPA?

From Dev

How to inject a @Named bean into a Junit test

From Dev

How to inject the same bean instance into multiple beans

From Dev

How many ways to inject the bean automatically in spring?

From Dev

Dagger with Android: How do I inject the current context?

From Dev

How to inject services into JavaFX controllers using Dagger 2

From Dev

How to inject a list or a set in Dagger as we can do it in Spring?

From Dev

How to inject dependencies into any kind of object with Dagger2?

From Dev

How to inject dependency in a Quartz job using Dagger 2

From Dev

Android IOC Dagger Framework - How to inject a nested field ?

From Dev

Dagger with Android: How to inject context when using MVP?

From Dev

How do I inject fields at runtime using Dagger 2?

Related Related

  1. 1

    Inject view in fragment with AndroidAnnotations

  2. 2

    How to tell Junit/Mockito to wait for AndroidAnnotations to inject the dependenices

  3. 3

    How to inject one bean to a set of bean in spring?

  4. 4

    How to inject ApplicationScoped bean in Stateless bean?

  5. 5

    How to inject raw Class to bean

  6. 6

    How to inject bean in a Tapestry service

  7. 7

    How to inject raw Class to bean

  8. 8

    How to inject bean in a Tapestry service

  9. 9

    How do I inject into a Servlet with Dagger 2?

  10. 10

    How to inject an anonymous inner class with dagger?

  11. 11

    How to inject pojo dependencies using dagger 2?

  12. 12

    How to inject a prototype bean in a Spring singleton Controller

  13. 13

    How to inject a bean in this MongoDB connection case?

  14. 14

    How to correct inject map of bean in spring context

  15. 15

    How to inject a @Named bean into a Junit test

  16. 16

    Spring: How to inject a String bean to the constructor?

  17. 17

    How to inject fields in bean-methods?

  18. 18

    How to inject bean validator automatically enabled by JPA?

  19. 19

    How to inject a @Named bean into a Junit test

  20. 20

    How to inject the same bean instance into multiple beans

  21. 21

    How many ways to inject the bean automatically in spring?

  22. 22

    Dagger with Android: How do I inject the current context?

  23. 23

    How to inject services into JavaFX controllers using Dagger 2

  24. 24

    How to inject a list or a set in Dagger as we can do it in Spring?

  25. 25

    How to inject dependencies into any kind of object with Dagger2?

  26. 26

    How to inject dependency in a Quartz job using Dagger 2

  27. 27

    Android IOC Dagger Framework - How to inject a nested field ?

  28. 28

    Dagger with Android: How to inject context when using MVP?

  29. 29

    How do I inject fields at runtime using Dagger 2?

HotTag

Archive