Android Kotlin retrieve context from an object

  android, kotlin

Hey I’m using Android Studio with Kotlin and I have an activity and a service that both needs to call same methods, so I created an object with theses methods in it, which would be like a utils class.

The problem is that the methods depend on a field that needs the application context to be created, and the only way I found to retrieve the context was to pass it through the constructor, but as it’s an object I can’t do that.

How could I keep that object behaviour and retrieve the application context ?

Source: Android Questions