Android service: dependency injection?

I am trying to disable my service through ServiceTestCase , but try to do this without using Guice or RoboGuice (due to Avoid dependency injection frameworks ). I want to add a dependency that is different from the application or context, but I cannot get it to work:

  • I cannot insert it through a custom constructor
  • setupService () will look like the correct name-based method, but has no arguments and does not return a value

I could make my Parcelable utility class and inject it through Intent, but that seems forced. Any ideas?

+4
source share

Source: https://habr.com/ru/post/1526307/


All Articles