Created
August 25, 2017 09:17
-
-
Save BurakDizlek/947341baa8d899eea44570c29362f2ca to your computer and use it in GitHub Desktop.
Application Class Sample for access context in everywhere
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApplication : Application() { | |
//sample usage : MyApplication.context | |
override fun onCreate() { | |
super.onCreate() | |
instance = this | |
} | |
companion object { | |
private var instance = MyApplication() | |
val context: Context | |
get() = instance.applicationContext | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment