title: Injecting class into a service
body: <p>I'm developing an android app, and I'm using MVVM pattern with Dagger, Databinding, etc.</p>
  
  <p>Currently I have a network layer called DataManager which injects in every ViewModel. This Datamanager class is the one who makes request to my server.</p>
  
  <p>It look like this </p>
  
  <pre><code>   @Singleton
      class DataManager @Inject constructor(context: Context, private val sharedPreferences: ISharedPreferences, private val apiHelper: APIHelper) : IDataManager {
  ...
      }
  </code></pre>
  
  <p>Everything works fine with fragments/activies but now I want to start a service and make a request in the background but I'm not sure <strong>how should inject my data manager class in the service.</strong></p>
  
  <p>Service looks like:</p>
  
  <pre><code>class UploadService constructor() : BaseTaskService() {
  
      private lateinit var filePaths: ArrayList&lt;String&gt;
      private var sourceID: Int = 0
      private var typeID: Int = 0
  
  ...
  onStartCommand ..
  onBind ..
  }
  </code></pre>