Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SurajBahadur/709bda055b7d1546c0ed67d6af3d7fce to your computer and use it in GitHub Desktop.
Save SurajBahadur/709bda055b7d1546c0ed67d6af3d7fce to your computer and use it in GitHub Desktop.
How to set global variable in Kotlin
  1. put this on top:
object GlobalVariable {
    var mp = MediaPlayer()
}
  1. use it everywhere GlobalVariable.mp

  2. so you won't have to worry about open too many MediaPlayer at the same time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment