생성된 개체가 현재 어떤일이 일어나는지 알 수 있도록 해줌
-> 어플리케이션에 관해 시스템이 관리하고 있는 정보에 접근할 수 있는 추상 클래스
init{
instance = this@클래스 이름
}
companion object{
private var instance:GlobalApplication? = null
fun applicationContext() : Context {
return instance!!.applicationContext
}
}
사용법
Application 을 상속받는 클래스 이름.applicationContext()