Skip to content

Instantly share code, notes, and snippets.

@BurakDizlek
Created August 25, 2017 09:17
Show Gist options
  • Save BurakDizlek/947341baa8d899eea44570c29362f2ca to your computer and use it in GitHub Desktop.
Save BurakDizlek/947341baa8d899eea44570c29362f2ca to your computer and use it in GitHub Desktop.
Application Class Sample for access context in everywhere
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