DEV Community

sunj
sunj

Posted on

Kotlin, application context 가져오기

android:name=".MyApplication"
Enter fullscreen mode Exit fullscreen mode
class MyApplication : Application() {

    init{
        instance = this
    }

    companion object {
       lateinit var instance: MyApplication
        fun ApplicationContext() : Context {
            return instance.applicationContext
        }
    }

}
Enter fullscreen mode Exit fullscreen mode

참조 : https://ddangeun.tistory.com/78

Top comments (0)