```class App : Application, SomeBehavior by someOb...
# android
u
Copy code
class App : Application, SomeBehavior by someObject
@no, this line is invalid, as I have no access to someObject in class declaration.
m
You can pass one as a parameter:
Copy code
class App(private val someObject: SomeBehaviour) : Application, SomeBehaviour by someObject
p
You would need to also have a default constructor, otherwise Android doesn't know how to create the application object
n
yeah, looks like you can’t do it then. the default contructor would be the only one constructed by the android system
p
I think it'd be ok as long as the default constructor injects that object somehow. If it needs to be set after the application starts then probably some sort of decorator could work.
g
someObject can be top level property or Singleton, than it will work, but you don't have access to Application in this case, only if you have some lazy semantics and have application instance accessor
👍 1
s
u
thanks, I'll check it out
g
This API added only in Android P, so most applications can use it in probably 5-10 years.