Sudhir Singh Khanger
09/25/2018, 4:59 PMclass CustomApplication: Application() {
companion object {
private var INSTANCE: CustomApplication? = null
@JvmStatic
fun get(): CustomApplication = INSTANCE!!
}
override fun onCreate() {
super.onCreate()
INSTANCE = this
}
}
Or
class CustomApplication : Application() {
companion object {
lateinit var instance: CustomApplication
private set
}
override fun onCreate() {
super.onCreate()
instance = this
}
}
Not sure if this is more appropriate for #android. Which one would you prefer for creating an Android Application class? And why?edwardwongtl
09/26/2018, 4:32 AM